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

3

2

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.

Etem answered 21/2, 2010 at 11:52 Comment(2)
As per below what you probably want is an executable JAR, which is really just pointing to the main class in your package that you want to run when the user calls java -jar yourJar.jarPlanoconcave
possible duplicate of How can I convert my java program to an .exe file ?Coextend
G
2

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.

Gillan answered 21/2, 2010 at 12:27 Comment(0)
B
2

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).

Brashy answered 21/2, 2010 at 12:0 Comment(0)
G
2

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.

Gillan answered 21/2, 2010 at 12:27 Comment(0)
P
0

You can also use Tanuki's Java Service Wrapper

Phifer answered 21/2, 2010 at 12:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.