如何制作jar文件?

发布于 2024-08-19 17:46:18 字数 38 浏览 2 评论 0 原文

如何从命令行和 Netbeans 6.7 生成 jar 文件?

How can i make a jar file from both the command line and Netbeans 6.7?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

格子衫的從容 2024-08-26 17:46:18

使用 JAR 命令:

jar cf jar-file input-file(s)

使用 Maven

<packaging>jar</packaging>

使用Ant

 <jar destfile="${dist}/lib/app.jar" basedir="${build}/classes"/>

Using the JAR command:

jar cf jar-file input-file(s)

Using Maven:

<packaging>jar</packaging>

Using Ant:

 <jar destfile="${dist}/lib/app.jar" basedir="${build}/classes"/>
待"谢繁草 2024-08-26 17:46:18

命令行:

jar cf jarfile [ -C dir ] inputfiles

确保您从与包层次结构匹配的目录的根目录开始 jar,而不仅仅是包含类文件的目录。目录结构需要与层次结构相匹配。

另外,如果您希望 JAR 可执行,则需要包含 MANIFEST.MF 包含一个 Main-class 条目,指定应将哪个类用作入口点(此类必须定义一个 public static void main(String[] args))。

Netbeans:这里是 教程

Command line:

jar cf jarfile [ -C dir ] inputfiles

Make sure you are jar-ing from the root of the directory matching your package hierarchy, rather than just the directory with the class files. The directory structure needs to match the hierarchy.

Also, if you want the JAR to be executable, you need to include a MANIFEST.MF containing a Main-class entry specifying which class should be used as the entry point (this class must define a public static void main(String[] args)).

Netbeans: here is a link to a tutorial.

半衬遮猫 2024-08-26 17:46:18

有很多方法(这里已经回答了足够多的问题),但如果您想要一种非常简单的方法,请查看 Maven。它只是有效:http://maven.apache。 org/guides/getting-started/maven-in-五分钟.html

There are many ways (enough already answered here), but if you want a REALLY SIMPLE way, look at Maven. It just works: http://maven.apache.org/guides/getting-started/maven-in-five-minutes.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文