• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

How to create an executable in java

 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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,
 
Ranch Hand
Posts: 1143
1
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 329
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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,
 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
They worship nothing. They say it's because nothing lasts forever. Like this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic