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.开发者_JAVA技巧 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.
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.
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).
You can also use Tanuki's Java Service Wrapper
精彩评论