This content has been marked as final. Show 5 replies
1. You don't really need to copy stuff out of the jre. Directly from the jre you can execute java.exe.
2. Your dont need the -jar
3. Looks like you named your jar in the commandline, but not the class you actually want to execute.
java -cp c:\test\untitled2.jar MyClassWithMain
(Substitute the name of the class which has your main method)
Your syntax was correct but you need to check wether your MANIFEST.MF resides in the directory META-INF in the .jar file.
You also need to check wether this MANIFEST.MF contains a line like
Note that everything is case-sensitive!
And about your question wether jre.exe is replaced with java.exe: this is indeed true.
try to check that you really have the manifest file with: jar -t untitled2.jar
If it does have it, are you sure you have the line "Main-Class: classname" in it?
Running the jar file can then be done with java -jar untitled2.jar
Thanks for the replies. I tried what you said :
I've replaced "untitled2.jar" with "loofabtest.jar" (actual name of the program)
The program is 2 java source files (loofabtest.java and frame1.java) , the main file is contained in
public class loofabtest within in loofabtest.java. The JAR file created is called loofabtest.jar
As I said previously the program runs OK from within jbuilder. All files & class names are lower case.
I used winzip (version 7.0) to open loofabtest.jar.
When I open loofabtest.jar there is a file called Manifest.mf with a path:
when I open that there is NO line
Main-Class: my.main or similar
So I edit the Manifest.mf file & added a line :
Query 1: is this syntax right or should the line read: Main-Class: loofabtest.class
after editing the file , when I save it I get an overwrite option , if I say no , I end up with 2 manifest files (which I think wont work) If I yes to overwrite , the file loses the
path (i.e. there is no path)
I tried editing the manifest in jbuilder , but with no luck (jbuilder autogenerates the manifest)
I also tried extracting all the files in the JAR , editing the manifest , then rearchiving them. I get the error message
java.io.IOException: invalid manifest format
at java.util.jar.Manifest.read(Compiled Code)
Query 2 : Is there an easy way to edit the manifest file to add the line needed and keep the meta-inf\ path?
Use the "jar" command line tool distributed with the JDK:
The file manifest.txt should have the text "Main-Class: loofabtest" and a line break. DON'T forget the line break!
jar vcmf manifest.txt loofabtest.jar loofabtest.class frame1.class