How To Use JPackage to Create an exe and msi Installer for JavaFX 17 App on Windows 11 x64 1-2

preview_player
Показать описание
In this guide, I'll demonstrate how to utilize JPackage to generate a self-contained JavaFX or Java 17 application that includes all essential dependencies. This will enable us to create a native package in the form of an EXE or MSI on Windows 11 x64.

JPackage has various customizable options to tailor the packaged application to meet specific needs.

--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.

You should download and install the following:

The Installed directories are as follow:

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

VM options:
--module-path "C:\Program Files\Java\javafx-sdk-17.0.1\lib"

JDK 17.0.1
JavaFX 17.0.1
JavaFX SceneBuilder 17.0.0
IntelliJ IDEA 2021.3
Windows 11 x64

JPackage command:

Source:
Рекомендации по теме
Комментарии
Автор

Hello, I tried your tutorial and it's working on converting to .exe but when I try to run the exe file it said "Failed to launch JVM" . can you please help what's going on?

Thank you

fahrezyman
Автор

Wow, thank you so much for this tutorial on JavaFX and JPackage! I've been looking for this info for several days. I was just redirected to JPackageScriptFX all the time, and I felt I was in over my head. But you just explained what I need to do, and it helped me understand the JPackage documentation as well. Now I just need to modify your program options a little and I can get it to work on Linux and Mac, and I can finally release cross-platform applications.

waltergabrielseniii
Автор

You save my life bro, thanks a lots <3

thanhnguyenuc
Автор

Hello Ken, I have core java windows application using Swing and AWT component, I haven`t used any kind of JavaFX Components. So how can I create native "app-image" of my application using JPackage?.

merapal
Автор

I get this error ObjectNotFound: (jpackage:String) why?

OsRageh
Автор

Ken,

Thank you for this video; it helped me immensely. This is the only tutorial I could find that describes what should be in the input directory.

A few nits:

(a) If your main jar (JavaFXHelloWorld.jar in this case) has a META-INF/MANIFEST.MF file that declares the main class, then I don't think you need to use the --main-class option on the jpackage command line (but it doesn't hurt).

(b) You specified the input directory as C:\Users\Ken\IdeaProjects\JavaFXHelloWorld\out\artifacts\JavaFXHelloWorld_jar, so I think you inadvertently included App-1.0.exe and App-2.0.msi in My App-2.0.msi. This doesn't have any effect on the program execution; but it does make the resulting output larger.

blenddynamics
Автор

Hi ken, can i use similar way to generate exe for my java swing project?

niharprabhu
Автор

Hi Ken, Does the artifact has to be runnable? I mean it has to run when I double click on it in Explorer?

catzillaw
Автор

Can not find WiX tools (light.exe, candle.exe)

pliniopvv
Автор

Thank you for this christmas gift, its awesome. Can you give me some clue of how to achieve this if I'm using gradle.

juang.