i want to do something like Jar cvf file.jar *.class but i don't see a jar compiler file 开发者_如何转开发in my jre6 java install. is the jar something separate i'm suppose to fine and install?
You need to download the JDK. That tools is included on the JDK, not the JRE.
The basic steps are (this will only package your class files into a jar (~zip) file):
- Download the jdk from here and install it
- Open a terminal and go the the directory and type
jar cvf file.jar *.class
- Run the jar file by
java -cp file.jar your.package.MainClass
If you want to make it directly runnable ("double-clickable" or java -jar file.jar
) then add a manifest like this tutorial.
If you do not need any special information placed in MANIFEST.MF a jarfile is just a zip file and you can use any zip tool to create the zip file and rename it afterwards.
精彩评论