Originally published on: Sun, 16 Aug 2009 13:46:59 +0000
I noted today that a successful independently written / marketed ( MicroISV ) product had been built in Java. The redistributable files were available for both Windows and MacIntosh computers.
Cross-platform Java executable wrapper Launch4j is a cross-platform tool for wrapping Java applications distributed as jars in lightweight Windows native executables. The executable can be configured to search for a certain JRE version or use a bundled one, and it's possible to set runtime options, like the initial/max heap size. In this tutorial we will discuss How to Convert jar to exe Using launch4j, free software to convert from jar to exe we can get it for free because the software launch4j licensed BSD, for those of you who do not already have software launch4j you can download launch4j first to be directly convert jar to exe. Before we start to convert.jar to.exe way we need to know in advance what is the.jar.
I emailed the author, asking what he used to build the installations for each. I’ll discuss the Mac software in a later post. For the Windows installation, he pointed me to a product called launch4j. ( See http://launch4j.sourceforge.net/ ).
Launch4j is an all-Java program that will bind a configurable Windows stub executable file to a Java jar file. The result is a jar embedded in a specially configured EXE.
When invoked, the EXE will execute the system’s appropriate JVM ( or will issue an error message if a compatible JVM hasn’t been found ) and will then execute the embedded jar file in this JVM.
Effectively, launch4j bottles up Java code into a Windows EXE.
Since launch4j is an all-Java program, one can actually build Windows EXE’s on various supported non-Windows platforms.
Let’s take a trivial sample Java program and turn it into an EXE with launch4j.
HeyGuys.java
Enter the following to compile and execute the program:
The message:
…should appear on the screen. Click OK.
Let’s take the file HeyGuys.class and put it in its own jar file. We first need to create a manifest file so that the jar will contain metadata to indicate which class should be executed via java.exe or javaw.exe.
Enter the following two lines in a file called manifest.mf:
Then, issue the following command:
Executing the above command should yield the file heyguys.jar.
Now, let’s try to execute the jar to see if we’ve packaged it up correctly.

Launch4j Java 14

You should see the same message window that was displayed earlier:
Finally, let’s use launch4j to package up the jar into an EXE.
Although launch4j has a command-line interface, I first used the GUI. The first screen I filled in looked similar to this:
I tried to just save the EXE at that point, but I then needed to specify a minimum Java version on this tab:
After changing those values, launch4j wanted me to save those options in an XML file, so I just chose the name l4j.xml arbitrarily.
Launch4j then quickly packaged a small EXE.
If you run it on a version of Windows with Java 1.6.0 or above, you’ll see the message window. If you don’t have a 1.6.x JVM, you’ll be prompted to download one.
Note that launch4j is not an installer. Now that you have an EXE, you might want to build an installer around it with a product like Inno Setup or the NSIS installer system.
Also note that in addition to the bare options that I’ve chosen, a number of other options are available including the ability to set an icon and the ability to specify the JVM’s runtime parameters such has heap size.
The source code and EXE for the above sample program can be found here:

Launch4j is a cross-platform tool for wrapping Java applications distributed as jars in lightweight Windows native executable files. In this post, we will learn making such an executable file for a demo java application.
Java Launch4j Install
Step1 ) Create a java application
I am creating a very basic java class which simply displays a frame and some text on it. It also has the main() method which will start the application.
Step 2) Create maven file with launch4j configured in it
I have created a pom file for packaging the application as .exe file. If you feel something unclear, drop a comment.
Java Launch4j Free
Step 3) Create .exe file

To make the exe file for above java program, run maven command:
Above command will create the “howtodoinjava.exe ” file in your project’s target folder. Double click on .exe file will open the window like this.
Java Launch4j Linux
If you want to download source code of above application, click on below given download link.
Java Launch4j Gradle
Happy Learning !!