开发者

How do I create a .jar cild

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):

  1. Download the jdk from here and install it
  2. Open a terminal and go the the directory and type jar cvf file.jar *.class
  3. 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜