Question:
i have a simple java program which contains has test.java and test.class, how do i make a jar file?
anonymous
1970-01-01 00:00:00 UTC
i have a simple java program which contains has test.java and test.class, how do i make a jar file?
Four answers:
tanmay.rathod
2009-09-27 21:14:02 UTC
well, you will need to package these files first and then execute jar commands. It is very easy if you are using netbeans or otherwise you can check out the source link here and it will explain you the concept of jar file and how to proceed. I hope this helps.
deonejuan
2009-09-26 20:22:51 UTC
All the .jar needs is the .class.



I have spent a day or two trying to get the java .jar utility program to pack a .jar. The think is: the jar contains a text file inside called Manifest. You can't edit that manifest file externally (otherwise malware would be a trivial exercise). The manifest will have the path to the main() of the class that starts your application.



You could write an ANT script.

You could use the java -jar command (with switch options) -m filename

or NetBeans



NetBeans is the easiest. You MUST do the following.

1. Select your Project in the Project Tree -- highlight it, right-click, "make main project"

2. In the menu Run --> Build and Clean...

(or hit Shift + F11 )



inside your project folder will be a new one created /dist

inside dist will be your .jar



.jar will execute as dbl-click on a Win desktop

or run from terminal as java -jar MyGiftToComputersEverywhere
David
2009-09-26 19:45:48 UTC
Netbeans will make the jar file for you already. Check the folder that netbeans creates.



To build the jar file, hit the build clean button. This will make a jar file in the dist folder.
Mark aka jack573
2009-09-29 23:31:42 UTC
You can get some step by step instructions at this tutorial on making jar files.



http://java.sun.com/docs/books/tutorial/deployment/jar/index.html



Good luck with it.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Continue reading on narkive:
Loading...