Welcome to my blog, hope you enjoy reading

Tuesday, 25 June 2013

create the executable jar file using java

create the executable jar file using java

To create the executable jar file using java do following steps
  1. create the swing based UI in java and generate the .class file 
  2. after creating the mainfast file your choice (.txt ) and you will give the java class name like           Main-Class: TestApp  
  3. the above step2 ,you have write the Main-Class: after given one space and press two times enter button in keyboard
  4. C:/>jar cmf test.txt myjarfilename.jar *
  5. you have generate the executable jar file
    1. for ubuntu os you can give the permistions
    2. chmod +x myjarfilename.jar.

Creating an Executable Jar Files in Eclipse

  1. Highlight the appropriate file/project
  2. File -> Export
  3.  Choose "Runnable JAR file" -> Next
  4. Make sure the right project is selected under the "Launch Configuration" dropdown and select "Package required libraries into generated JAR file" under the "Library Handling" section and make sure it's going to the correct export destination. 
  5. click Finish

Now you should have the jar file in the destination you told it to export to. Double click it and it should run. 
**HOWEVER** If this is a command line program it will not run. To run a command line program, after doing the above steps, open the command prompt, cd to the correct directory, and execute it by typing
  java -jar name_of_file.jar