Search This Blog

Monday, June 28, 2010

How to create a jar file

  1. First, make sure you have installed Java 1.2 or above. This facility is not available in previous versions of Java.
  2. Now create a program and place it in a separate folder.For example the main class is hello world. so first compile it using the statement
    javac helloworld.java
  3. Now you will find a file named helloworld.class
  4. Now in that same folder you create a file Manifest.mf
  5. The first line should be --- Main-Class: helloworld
  6. Now save the file
  7. Now open the command promt in that folder.
  8. Type the line --- jar cfm helloworld.jar Manifest.mf *.class
  9. Give enter and your jar file would be created.
  10. If you have gif images used in the program then place the images in that folder and type the given line in the commandline ---- jar cfm helloworld.jar Manifest.mf *.class *.gif
  11. Now your jar is created .Click on it to run it.
  12. Note :: all the commands and file name are case sensitive.

No comments:

Post a Comment