如何创建Java项目的JAR / exe? [英] How can I create a JAR/exe of a Java project?

查看:112
本文介绍了如何创建Java项目的JAR / exe?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用NetBeans 6.1开发了一个Java项目。我需要在它中添加两个第三方JAR和在JDK / JRE / bin位置添加两个许可文件。

I have developed a project in Java using NetBeans 6.1. I need to add two third party JARs to it and 2 license files in a JDK/JRE/bin location.

现在我希望它将其分发用于试用。我没有创建Java项目的经验。任何人都可以解释一下如何做到这一点?我在发布之前尝试了一些命令,但它们没有用。

Now I want it to distribute it for trials. I have no experience in creating exes of Java projects. Can anybody please explain how to do this? I tried some commands before posting here, but they did not work.

推荐答案


我需要添加2个第三方jar到
它和
jdk / jre / bin位置的2个许可文件。

I need to add 2 third party jar's to it and 2 licence files in a jdk/jre/bin location.

您不应该向该目录添加任何内容。需要与可执行JAR一起使用的第三方JAR和许可文件属于您的项目。

You should not be adding anything to that directory. Third party JARs and license files that need to go along with your executable JAR belong with your project.

如果.java文件位于/ src目录中,请创建/ lib目录并将第三方JAR和许可证文件放入其中。将它们添加到NetBeans CLASSPATH中,以便编译和运行代码。

If your .java files are in a /src directory, create a /lib directory and put the 3rd party JARs and license files into it. Add them to your NetBeans CLASSPATH so your code will compile and run.

当您准备创建可执行JAR时,请确保创建META-INF /清单.mf文件指向您的主类并将这些JAR添加到其类路径。

When you're ready to create your executable JAR, make sure you create a META-INF/manifest.mf file that points to your main class and adds these JARs to its classpath.

如果可行,您还需要再执行一步。您必须将可执行JAR和第三方库进行压缩,以便客户可以解包他们需要运行的所有内容。

If that works, you'll have one more step to deploy. You'll have to ZIP up your executable JAR and the 3rd party libraries so your clients can unpack everything they need to run.

这篇关于如何创建Java项目的JAR / exe?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆