Hallo expert people, i have made a jar file with the following command : jar cf backup.jar backup_pro.class backup_pro$zip.class ... and if i run with the following command : java -jar backup.jar , it will work but if i double click there is an error "Could not find the main class. Program will exit!". Have any one experience how to make jar file executeable with double click. I have download many jar files from internet and they are working with double click and "java -jar jarfiles.jar" command. Any Help will be appreciated.
You should write your own Manifest.mf file and force the Java Jar utility to use it with the -m command. Your Manifest.mf file should have an entry called "Main-Class" that points to the class in your application that has the
method. An example Manifest.mf file would look like:
Joined: Jan 15, 2005
My MANIFEST.MF seems right as yours, here is the content of my Manifest file :
where backup_pro is the main class, the jar file that i create "backup.jar" work with the following command "java -jar backup.jar" but not with double click. What do you mean with -m ? can you give a complete command ? thank you very much.
Joined: Mar 09, 2005
The -m command simply tells the Jar utility to package the Manifest.mf file you wrote within the Jar. An example command would look like:
jar cmf Sample.mf Sample.jar Sample.class Turtle.class Sample.java Turtle.java images
You can find a more complete exlanation in this tutorial: