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 create an executable in java 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 create an executable in java" Watch "How to create an executable in java" New topic

How to create an executable in java

Mario A. Villamizar
Ranch Hand

Joined: Mar 14, 2002
Posts: 35
How can I create an executable file in java, I've seen some programs that I have downloaded from the internet made in java that are ".jar" and you only double-click on it un runs.
Can you give me some hints or any link wherer I can get some information on this issue?
Many thanks,

MA Villamizar
Avi Abrami
Ranch Hand

Joined: Oct 11, 2000
Posts: 1141

Hi Mario,
If you haven't already seen it, this Web page may be helpful:
Good Luck,
Ronnie Phelps
Ranch Hand

Joined: Mar 12, 2001
Posts: 329
Mario here's a quick easy lesson on creating executable jar files. Once you have created a jar file you must create a manifest file which has the folowing text:

Main-Class: my.package.MyMainClassName

Note the file has two lines. One with the main class and another blank line. Also my.package.MyMainClassName will be replaced with the fully qualified name of the class which contains your main method.
Once you have created the file you can make an existing jar file executable by executing this at the command line:

jar -umf manifest Existing.jar

and to run it you will need to call

java -jar Existing.jar

Hope that was helpful.
Mario A. Villamizar
Ranch Hand

Joined: Mar 14, 2002
Posts: 35
hi many thanks, that was really helpful. I created my executable jar file, but I got a new problem; I've got the following structure:
The workspace is bin (folder)and inside this folder I've got the editor (folder) package and images(folder where there are all the images for the buttons). Inside the editor package is the JTEdi.class, which is the class that has the main method and as well some other packages.
to create the jar file from the command line, I stand in the bin folder and type:
jar cmf jtedi.jar editor images
after that it created a jtedi.jar inside the bin folder and to run it I typed: java -jar jtedi.jar
All that work just perfect, but if I put the jtedi.jar file in another folder and type from the command line the same java -jar jtedi.jar it works but it doesn't display the images on the buttons, intead (I'm using actions) it displays the description of the action.
what could be the problem?
Thanks again,
Gaurav Mac Mathur
Ranch Hand

Joined: Feb 19, 2002
Posts: 47
Well I am tryign teh same but while trying to Modify the jar i am getting this error,
jar -ufm Application.jar manifest manifest (No such file or directory)
at Method)
tte manifest file is present so is the jar file...
Whats wrong ??? :roll:
I agree. Here's the link:
subject: How to create an executable in java
It's not a secret anymore!