Creating an executable file with Launch4J and Java 11

How to build an executable file for a Java 11 GUI application using Launch4J

Before we look at the how perhaps we should ask the question of why.  The aim is to package up our Java application so that we can distribute it to others. We want them to be able to launch the application without having to install anything else.

Therefore, what we are looking to deliver is our Java application along with the Java Runtime Environment and any external libraries required for it to run. To do this will need a few tools:


Assuming you have Java 11 installed on your machine and it is the default Java installation then you will have issues trying to run the Launch4J executable program that is installed.  To run Launch4J open a cmd prompt and go to the directory where you have installed Launch4J and type “java -jar launch4j.jar” and press enter.

The Lanch4J application will open.

Launch4J default screen
Launch4J default screen when launched

On the Basic tab

Specify an output file, I used “C:\Temp\sun2\sun.exe”

Specify the location of the JAR file, I used “C:\Temp\sun2\app2\sunlounger.jar” I chose to use an icon for my application but this is optional, I used “C:\Temp\sun2\sunbed.ico

Launch4J populated basic tab
Launch4J Basic tab populated with values required for the example

On the Header tab

Make sure the Header type radio button for GUI is selected

Launch4J Header with settings for GUI
Launch4J Header tab with settings for the example application

On the JRE tab

Specify the Bundled JRE paths, I used “fxjre”.
This does not package the JRE into the executable file, the executable file will look for a folder called “fxjre” relative to where the executable file is located and this should contain the JRE

Specify the Min JRE version, I used 11.0.2

Launch4J JRE tab with basic settings
Launch4J JRE tab populated with values for the example application that uses a Java 11 JRE

That’s all you need to do. Press the gear icon to build the executable file

Folder contents after running Launch4J
Folder contents after running Launch4J to build the executable file.

To check your application runs, double click the sun.exe file and the application should launch.

Sunlounger application screen
Sunlounger application screen displayed after running sun.exe

However, you have JDK 11 installed on your machine, so this is not a good test.  Ideally what you need is a machine that you know does not have Java 11 installed and test it on that machine.

To deploy to another machine, you will need to install

  • Sun.exe
  • Folder fxjre

The fxjre folder and its contents are the JRE your application requires to run; it is not wrapped into the executable file so you need to make sure it is added to the target machine along with the executable file.  Do not change the folder name.

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.