wood burning stoves*
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
Author

How to create an executable in java

Mario A. Villamizar
Ranch Hand

Joined: Mar 14, 2002
Posts: 35
Hi,
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: 1131

Hi Mario,
If you haven't already seen it, this Web page may be helpful:
http://www.yoda.arachsys.com/java/javaexe.html
Good Luck,
Avi.
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 manifest.mf 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
java.io.FileNotFoundException: manifest (No such file or directory)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:103)
at java.io.FileInputStream.<init>(FileInputStream.java:66)
at sun.tools.jar.Main.run(Main.java:164)
at sun.tools.jar.Main.main(Main.java:904)
tte manifest file is present so is the jar file...
Whats wrong ??? :roll:
Regards
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How to create an executable in java