Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to Create JAR File
11-19-2011, 01:28 AM
Post: #1
How to Create JAR File
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.
Find all posts by this user
Add Thank You Quote this message in a reply
Post Reply 


Possibly Related Threads...
Thread: Author Replies Views: Last Post
Photo Convert jar to exe file rajasri 2 567 02-05-2012 04:12 PM
Last Post: thxq
Sad create a file from form input in java,jsp rajasri 0 100 12-19-2011 11:02 PM
Last Post: rajasri
Information create a war file using jsp code rajasri 0 86 12-19-2011 10:48 PM
Last Post: rajasri
Sad how to delete a file using jsp rajasri 0 79 12-19-2011 10:32 PM
Last Post: rajasri
Sad how to import a csv file values in to database using jsp rajasri 0 399 12-14-2011 04:51 PM
Last Post: rajasri
Music How to extract war file in java rajasri 0 850 12-14-2011 04:37 PM
Last Post: rajasri
Its My Birthday! Dynamic Chart In Jsp/Create chart in jsp Part-1 rajasri 0 279 12-13-2011 03:40 AM
Last Post: rajasri
Photo How to import a war file in to eclipse rajasri 0 530 12-13-2011 03:32 AM
Last Post: rajasri
Photo how to add .properties/.jar file to classpath in eclipse rajasri 0 679 12-12-2011 11:56 PM
Last Post: rajasri

Forum Jump:


User(s) browsing this thread: 1 Guest(s)


WE will share important jobs and updates on facebook so like us to get updates