Creating executable JavaFX application — Part 2

Vinay Prabhu
3 min readJul 24, 2019

This tutorial is to create a desktop application using JavaFX and create an executable file from the code.
Read the part 1 of tutorial over here

Now that the application is running, the file structure would look something like this.

Creating jar from JavaFX application

1. To create an executable jar, press ctrl + shift + alt + s or go to file -> project structure.
Select Artifacts.

2. Click on + button and select JAR and click on From modules with dependencies.

3. Select the Main Class as home and click on OK

4. The following screen would appear. In case you are using any external libraries, those can be added or omitted here. Click on Apply and OK

5. Now a META_INF folder will be created in src folder that consists of Manifest.

6. To create an executable jar, go to Build and select Build Artifacts.

7. Select the artifact and click on Build.

8. The jar will be generated in out/artifacts/project_name/project.jar

9. You can run the jar directly by typing the following command

java —jar file_name.jar 

Conversion of jar to exe

  1. Download Launch4J and install it.
  2. Launch the application and add the following details
    Output File: The location where exe has to be generated
    Jar: The jar that was built in the previous chapter
    You can also select an icon for the exe

3. Go to JRE tab and enter Min JRE version. I am entering it as 1.7.0

4. click on the gear icon to build wrapper.

5. The exe file will be generated in the destination directory

on running the sample.exe the application will be launched.

Thanks for reading.

--

--