简体   繁体   中英

How can I create a JAR/exe of a Java project?

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.

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.

You can use JSmooth for creating Windows .exe files (user manual is here ). Or you can make your deployed JAR file executable by adding some manifest options ( tutorial for Eclipse ).

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

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.

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.

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.

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.

您还可以使用Tanuki的Java Service Wrapper

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM