views:

110

answers:

5

I was asked to make a program (in java) by some person but I was stacked as I didn't know how to generate and exe file from my jar file... It would be useless If I install for them the jdk environment as this person don't how to program... Does anyone knows ho to do this or what tool should I use ?

Regards from Córdoba Capital, Argentina...Thanks in advance !!!

A: 

They don't need to install the entire JDK to run the jar file, all they need is the significantly smaller JRE. This is standard practice when distributing java applications.

A big advantage of running your java program on the jvm as compared to generating a native binary is that it will, assuming you aren't using a platform-dependent library, be platform-independent straight away.

Lucas Lindström
+2  A: 

Read this post, it may help
http://viralpatel.net/blogs/2009/02/convert-jar-to-exe-executable-jar-file-to-exe-converting.html

Regards
Thomas

Thomas
A: 

You can use Excelsior JET. It is not free, work quite slow, but you can create executable (very huge executable). I tested it on Windows and it worked. But executable it created was slower then .jar run using JRE.

There is also GCJ. I tried it, but it was too hard for me to compile my project.

I suggest installing JRE and working with .jar file.

Michał Niklas
A: 

Here is a post from earlier that has some other options: http://stackoverflow.com/questions/2288440/how-to-create-a-java-application-which-can-be-run-by-a-click

As Lucas mentions above, you will need to install the JRE on the user's machine to get a Java app to run properly. If it is a small program, you could consider making a .bat file (or .sh file on *nux) to allow the user to run the program. Your bat file could as simple as the one below. Just put in a .bat file and add as a short cut. I know there are more elegant solutions out there, but this is simple and should work.

setlocal
set CP=<PATH TO ANY DEPENDENT LIBRARIES OR JARS>
start javaw -cp %CP% <FULLY QUALIFIED MAIN METHOD> <PROGRAM PROPERTIES>
endlocal
Luhar
+1  A: 

You could use launch4J, it's pretty simple to use and to configure.

Valentin Rocher
Launch launch4j is also free. I've found it to be a good solution. It has an option to direct users to dl location if the correct JVM is not installed. Splash screen and other goodies as well. I've used it successfully in multiple projects.
David Hamilton