Dec 6, 2010

Steps for creating jar file (.jar) from java file

To Create jar file of any java program use under given steps


NOTE:     It is necessary that your program run in java then and then that
        program is ready to create a jar file
       
       
1.Go To Run open cmd
2.Go To Directory where your .java file reside
3.Compile .java file and create .class file
4.Use the under given syntax to create the jar file(use this in command prompt)
   
    Syntax-1:
   
        jar cf tejas.jar *.class
   
5.Now Extract the .jar file which is generated by the above syntax in your current
    directory
6.Open the extrected folder
7.Open the META-INF folder
8.Copy the MANIFEST.MF from META-INF
9.Paste that file in the folder where .jar file is generated
10.Edit MANIFEST.MF with Note Pad and write the under given syntax to that file
       
        syntax-2:
       
            Main-Class: test (.java name but without .java ex: test(test.java))
           
        now save that file and exit from edit
       
11.Go To command prompt and write under given syntax
       
        syntax:
       
            jar cmf MANIFEST.MF tejas.jar *.class
       
NOTE-1: Here in syntax-1 the tejas.jar is given by manually so you can give any
        name to your jar file ex: exam.jar,abc.jar
NOTE-2: Here in syntax-2 you give the .jar file name same as given in the syntax-1


So your jar file is Generated and ready to execute.....
       

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.