如何创建 .jar cild
我想做一些类似 Jar cvf file.jar *.class 的事情,但我在 jre6 java 安装中没有看到 jar 编译器文件。这个罐子是我想要罚款并安装的单独的东西吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您需要下载 JDK。该工具包含在 JDK 中,而不是 JRE 中。
You need to download the JDK. That tools is included on the JDK, not the JRE.
基本步骤是(这只会将您的类文件打包成 jar (~zip) 文件):
jar cvf file.jar *.class
运行 jar 文件java -cp file.jar your.package.MainClass
如果你想让它直接运行(“双击”或
java -jar file.jar
),那么添加一个清单,如< a href="http://download.oracle.com/javase/tutorial/deployment/jar/appman.html" rel="nofollow">本教程。The basic steps are (this will only package your class files into a jar (~zip) file):
jar cvf file.jar *.class
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.如果您不需要在 MANIFEST.MF 中放置任何特殊信息,则 jar 文件只是一个 zip 文件,您可以使用任何 zip 工具创建 zip 文件并随后重命名。
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.