Creating Jar in Java
Creating a jar file is easy in three step process first create the necessary class files and gif files( if you want to add it to the jar).
Step1: Create the class files and put it in a folder.
Step2:Create MANIFEST.MF file.
That file should contain the main method then only it will be executed when you double click it.
ex:Create a new notepad file and save it as MANIFEST.MF and add necessary entry like this
Main-Class: yourclassname
Method: yourmethodname
Sub-Class: yoursubclassname ifany
It Must contain Main-class others are optional.And put it in same folder where class file resides.
Step3:In cmd prompt within class folder give the commands as given below
jar cvfm anynameyoulike.jar MANIFEST.mf *.class *.gif *.dat
Sample o/p you get like below
added manifest
adding: yourclassname.class(in = 4823) (out= 2690)(deflated 44%)
adding: 45.gif(in = 35514) (out= 34772)(deflated 2%)
adding: jamal.dat(in = 385177) (out= 141285)(deflated 63%)
To Check your jar is created correctly by giving following commands,In cmd prompt
java -jar anynameyoulike.jar
That it you created jar file To execute it by double clicking you need to have Jre any questions ask us.