Question
Hi Michael,
For my application I need to create a Java .exe. What steps do I need to create one? Is there a tool that will help me do this automatically?
Answer
The standard Java development kit (JDK) supplied by Sun does not provide a tool to create platform specific executables (This is not suprising really). However, you do have a number of options to choose from that will help you get this done.
Third-party tools
One option is to use a third-party commercial or free tool to package your Java application as an executable file.
Below are two tools that vary in both features and price, but there are several others on the Web also available for download.
Use a commercial installer.
InstallAnywhere is a commonly used installer which will manage the installation
of your application and package your application for execution.
Use .jar
As an alternative, you may want to bundle your application as an executable .jar file instead of a .exe file. I won't go into the full details in this article but there is an excellent online tutorial here.
The essential thing you need to do is indicate which class within the .jar file is your application's entry point. For example, the bootstrap class for your application with a public static void main(String[] args) method. You can provide this information with the Main-Class header in the .jar manifest file. This header has the general form: Main-Class: classname ,where the value classname is the name of the class that is your application's entry point.
Use Java Webstart.
Java Webstart is one of the hidden gems of the standard Java runtime environment (JRE), and has been included with the JRE since version 1.3. It is a simple, but powerful and flexible way of deploying applications to any platform.
Webstart allows users of your application to launch and manage the application from their browser, e-mail or desktop. One of the key advantages of Java Webstart is that once the application is installed, everytime you start it, it will check to see if the user is running the latest version of the application. If not, the app will load and execute a new version over the network to the desktop and thus eradicates software currency issues.
This is particularly important if you have many users of your application. Importantly it also checks the local desktop environment of the user and will ensure that they have the appropriate version of the JRE installed to run your application.
Java Webstart is a series of articles in itself, so I would recommend that you visit the Java Webstart Web site for more documentation and tutorials.
Conclusion
The first two options will probably meet your needs for this question, but I highly recommend taking a close look at Java Webstart. It is part
of the Java standard and works consistently on all platforms. It is my preferred approach to application packaging.
Ask our Java Expert
Do you have a Java related question for Michael that you want answered? Forward your questions to builder@zdnet.com.au
Michael Geisler is a solutions architect with Sun Microsystems and has more than 14 years of experience in the IT and telecommunications industry. He has been working with Java since the first public beta and is currently the vice-president of the Australian Java Users Group (AJUG).
Do you need help with Java, C, or C++? 







1
Billy Crystal - 16/05/04
For third-part tools you can get a heifty list here:
http://www.dmoz.org/Computers/Programming/Languages/Java/Development_Tools/Deployment/Executable_Wrappers/
» Report offensive content
2
Andi - 24/03/05
Another option is to use the GPL tool "Xenoage Java Exe Starter", www.xenoage.com/jestart/
You can pack the Jar into the Exe, demand a certain JRE version, use an icon, and much more.
» Report offensive content
3
Andi - 24/03/05
Another option is to use the GPL tool "Xenoage Java Exe Starter", www.xenoage.com/jestart/
You can pack the Jar into the Exe, demand a certain JRE version, use an icon, and much more.
» Report offensive content
4
Denis Gurchenkov - 06/07/05
Hi Michael,
Your brief and informative article does not mention one more way to generate Java .exe, namely compile the .cl**** files into native code, just as one can do with C, C++ or Fortran programs.
There are two tools that can compile arbitrary Java program to real .exe:
GNU-based GCJ http://gcc.gnu.org/java
Excelsior JET http://www.excelsior-usa.com/jet.html
I work for Excelsior, so I do not want to compare the tools or compare them to another ways of making a Java .exe
Regards,
Denis Gurchenkov,
Excelsior LLC
» Report offensive content
5
Notrayan - 04/08/06
This article is good
send me some code regarding java application into exe
» Report offensive content
6
balu - 25/11/06
hi
how to create .exe(setup) file or instalation file for java application
» Report offensive content
7
chris - 19/12/06
i need to convert my java application which can do capturing the voice and stored in a folder in .wav format file.so, i hav to convert this file to a setup file(i mean it should be like software just set up in any system and start using it.
» Report offensive content
8
sumit - 27/08/07
code education
» Report offensive content
9
ItsVineeth - 17/12/07
Hi..
all the above links are related to creating Windows executables??
What abt linux...?
thanks in advance
» Report offensive content
10
joe - 01/05/08
i want u to help me convert java files to exe. files
» Report offensive content
11
j shrirang - 02/05/08
PLEASE GIVE ME DETAILS OF
HOW TO CREATE EXECUTABLE JAR FILE JAVA
» Report offensive content
12
mizan - 30/06/08
How can i make .exe file from stand alone java application program?
» Report offensive content
13
Sivavignesh - 22/07/08
hi, this is vignesh. I've planned to do my project in java with SQL Server. I've to convert my front end application as an .exe or .jar file. How can I convert that? plz reply this...
» Report offensive content
14
Tarubhi - 29/10/08
I need to know about converting a java application to executable format. Need it urgently!!!
» Report offensive content
15
Mohammed - 30/11/08
If I am gong to convert my java app to an exe file, will system in (input from user) and System.out.println still work? Or do I have to set up a GUI?
» Report offensive content
16
mansoor abbasi - 26/01/09
i don,t need code or beg for that ..i,ll construct the method to compile the java file as a exe file.....wait for me...thanks...
mansoor ahmed abbasi from: PAKISTAN.
» Report offensive content