Overview
jpackage (standard since Java 16, JEP 392) turns a Java application plus a runtime into
something end users can actually install: a native app image (a self-contained directory with a
platform launcher) or a platform installer — deb/rpm on Linux, msi/exe on Windows,
dmg/pkg on macOS. Users never install Java separately; the runtime travels inside the
package. It replaced the old JavaFX javapackager.
Key points
- Two-stage model: it first builds an app image (launcher +
app/with your jars +runtime/), then wraps it in an installer;--type app-imagestops after stage one. - Runtime bundling: by default jpackage runs jlink itself (use
--add-modules/--jlink-optionsto trim); or pass a pre-built image with--runtime-imagefor full control. - Platform-bound: it produces packages only for the OS it runs on and needs local packaging
tools (WiX on Windows,
dpkg/rpmbuildon Linux, Xcode command-line tools on macOS) — CI needs one build job per target platform. - Inputs: modular (
--module) or classpath (--inputdir +--main-jar/--main-class) applications both work. - Launcher polish:
--icon(.ico/.icns/.pngper platform),--java-optionsfor fixed JVM flags,--argumentsfor defaults,--add-launcherfor extra entry points, file associations via--file-associations. - Signing is on you: macOS Gatekeeper requires codesigning and notarisation
(
--mac-signand related options help); Windows SmartScreen expects Authenticode signing of the msi/exe, which jpackage does not do — sign afterwards withsigntool. - Not cross-platform, not an updater: no built-in update channel; pair with platform stores or an updater library if you need one.
Examples
jpackage --name MyApp --app-version 2.1.0 \
--input build/libs --main-jar myapp.jar \
--icon assets/myapp.icns \
--java-options '-Xmx512m' \
--type dmg
Related
- JDK & tools — parent catalogue of the JDK toolchain.
- jlink — builds the trimmed runtime jpackage embeds.
- jmod — link-time format behind the bundled runtime's JDK modules.
- jar tool — the application artefacts that go into
--input. - Build ecosystem — how packaging fits the Maven/Gradle release pipeline.