File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes How to make jar file executeable ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "How to make jar file executeable ?" Watch "How to make jar file executeable ?" New topic

How to make jar file executeable ?

benny rusli
Ranch Hand

Joined: Jan 15, 2005
Posts: 72
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.
Yevgeniy Treyvus
Ranch Hand

Joined: Mar 09, 2005
Posts: 48

You should write your own file and force the Java Jar utility to use it with the -m command. Your file should have an entry called "Main-Class" that points to the class in your application that has the

method. An example file would look like:

benny rusli
Ranch Hand

Joined: Jan 15, 2005
Posts: 72
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.
Yevgeniy Treyvus
Ranch Hand

Joined: Mar 09, 2005
Posts: 48
The -m command simply tells the Jar utility to package the file you wrote within the Jar. An example command would look like:

jar cmf Sample.jar Sample.class Turtle.class images

You can find a more complete exlanation in this tutorial:

Make sure your file is in the META-INF folder. An example structure would look like:


You can use something like Winzip to look at the contents of your Jar file. Make sure all needed .class files are indeed there.
Stefan Wagner
Ranch Hand

Joined: Jun 02, 2003
Posts: 1923

The manifest has to be correct, if you call 'java -jar xy.jar' too, shouldn't it?
So it shouldn't be the reason.

Suspicious, suspicious...

You're sure about the errormessage?
I agree. Here's the link:
subject: How to make jar file executeable ?
Similar Threads
"Executables" Win2000 - a solution
jar runs on desktop but not laptop
how to make my game program run , just in double click ?
Command Line from a jar
how to make executable program in java ?