Monday, 20 June 2011

How to make an executeable jar

Delivering desktop application developed in java, its very interactive that you give your software in a executable jar, rather giving .bat files (running java <main>.class)
To do that, try these steps.
First, jar all of your class files and let Java create it’s own manifest. First, make sure you are in the directory of your class files:
jar cvf MyJarFile.jar *.class
You would replace MyJarFile.jar with whatever you want the jar file to be named. Then, create a regular text file with this:
Main-Class: MainClass
Make sure you hit enter at the end. The file has to end with a carriage return. Say you name the text file ManifestUpdate.txt. Make sure you save it in the same directory as all your class files.
Then do this:
jar umf ManifestFile.txt MyJarFile.jar
This essentially updates the current Manifest file in your .jar file with the contents of the text file you created.
Again, go through the JAR tutorial. It will help you out a lot!
http://java.sun.com/docs/books/tutorial/deployment/jar/

No comments:

Post a Comment