How To Deploy an Executable JavaFX 19 JAR, exe, msi Using IntelliJ 2022.3.1 on Windows 11 x64 (3-3)

Опубликовано: 07 Октябрь 2024
на канале: Ken
676
15

This tutorial explains how to create a self-contained JavaFX 19 application using JPackage, including all required dependencies. The tool allows you to produce a native package in .exe or .msi format on Windows 11 x64.

The JPackage tool has several options that allow you to customize the packaged application, such as:

--type
The type of package to create

--input
Path of the input directory that contains the files to be packaged

--dest
Path where generated output file is placed

--main-jar
The main JAR of the application containing the main class

--main-class
Qualified name of the application main class to execute.

--module-path
The path to modular jars

--add-modules
Add list of modules

--win-shortcut
Creates a desktop shortcut for the application.

--win-menu
Adds the application to the system menu.

Source:
https://docs.oracle.com/en/java/javas...

You must download and install the following software:

JDK 19.0.2 from https://www.oracle.com/java/technolog...
Open JavaFX (OpenJFX) and JMODS 19.0.2 from https://gluonhq.com/products/javafx/
Java Scene Builder 19.0.0 from https://gluonhq.com/products/scene-bu...
IntelliJ IDEA Community Edition 2022.3.1 from https://www.jetbrains.com/idea/download/
WiX Toolset v3.11.2 from https://wixtoolset.org/releases/

The installed directories are:

C:\Program Files\Java\jdk-19
C:\Program Files\Java\javafx-sdk-19.0.2.1
C:\Program Files\Java\javafx-jmods-19.0.2.1
C:\Users\Ken\AppData\Local\SceneBuilder
C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2022.2.3
C:\Program Files (x86)\WiX Toolset v3.11

JPackage command

jpackage --type exe --input . --dest . --main-jar JavaFXHelloWorld.jar --main-class com.example.javafxhelloworld.App --module-path "C:\Program Files\Java\javafx-jmods-19.0.2.1" --add-modules javafx.controls,javafx.fxml --win-shortcut --win-menu

jpackage --type msi --app-version "2.0" --input . --dest . --main-jar JavaFXHelloWorld.jar --main-class com.example.javafxhelloworld.App --module-path "C:\Program Files\Java\javafx-jmods-19.0.2.1" --add-modules javafx.controls,javafx.fxml --win-shortcut --win-menu

jpackage --type exe --input . --dest . --main-jar JavaFXHelloWorld.jar --main-class com.example.javafxhelloworld.App --module-path "C:\Program Files\Java\javafx-jmods-19.0.2.11" --add-modules javafx.controls,javafx.fxml --win-shortcut --win-menu --icon "icon.ico" --name "My App" --app-version "2.0"

jpackage --type exe --input . --dest . --main-jar JavaFXHelloWorld.jar --main-class com.example.javafxhelloworld.App --module-path "C:\Program Files\Java\javafx-jmods-19.0.2.1" --add-modules javafx.controls,javafx.fxml --win-shortcut --win-menu --icon "icon.ico" --name "My App" --app-version "2.0" --description "JavaFX 17 Hello World App" --verbose

Note: How To Deploy JAR, exe and msi for JavaFX 17 Application on Windows 11 x64 (Updated)    • How To Deploy JAR, exe and msi for Ja...