Quick revision
The short answer
jpackage, final since JDK 16, turns a Java application into a native installer or a self-contained application folder. It uses jlink to build a trimmed Java runtime, or takes one we built, and adds a native launcher, so users install it like any other program and need no separate Java. It produces msi and exe on Windows, pkg and dmg on macOS, and deb and rpm on Linux, plus an unpacked app-image anywhere, and it must run on each target platform because it uses that platform's own packaging tools.
What to remember
In this answer, we saw that jpackage, final since JDK 16, bundles an application, a jlink runtime and a native launcher into a native installer or an unpacked app-image, so users need no separate Java. It handles both class path applications, with --input and --main-jar, and modular ones, with --module-path and --module. It produces msi and exe on Windows, pkg and dmg on macOS and deb and rpm on Linux, and because it drives each platform's own packaging tools and native binaries, it must run on every target platform.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
jpackage, final since JDK 16, turns a Java application into a native installer or a self-contained application folder. It uses jlink to build a trimmed Java runtime, or takes one we built, and adds a native launcher, so users install it like any other program and need no separate Java. It produces msi and exe on Windows, pkg and dmg on macOS, and deb and rpm on Linux, plus an unpacked app-image anywhere, and it must run on each target platform because it uses that platform's own packaging tools.
Why this question is asked
Shipping a desktop or command-line Java tool used to mean asking users to install the right Java first. jpackage removes that step, and interviewers ask about it to check that we know how modern Java applications are distributed now that Web Start is gone. In this answer, we will recap the problem jpackage solves, look at what goes into its output, run it for both a non-modular and a modular application, go through the formats per operating system, and see why there is no cross-packaging.
1A Quick Recap of the Problem
A Java application is a set of jar files, and jars need a Java runtime to run. For years, desktop tools shipped with instructions such as install Java 8, then double-click the jar. That breaks easily: the user has the wrong version, or none, or a corporate machine blocks installing it. jpackage takes the opposite approach. Each application carries its own runtime inside its installer, so the application decides the Java version and the user never sees Java at all.
jpackage arrived as an incubating tool in JDK 14 and became final in JDK 16, through JEP 392. It ships in the JDK's bin folder next to java and jlink.
2What the Output Contains
An installed jpackage application has three parts. There is a native launcher, a small executable such as MyTool.exe on Windows or MyTool inside a .app bundle on macOS, which starts the JVM with the right options. There is a runtime image, the folder that jlink creates, with only the JDK modules the application needs. And there is the application itself, our jars and resources, plus a configuration file that tells the launcher the main class, class path and JVM options.
- Installermsi, exe, pkg, dmg, deb or rpm
- Native launcher
MyTool.exeorMyTool; reads the .cfg file - Application filesOur jars, resources and
MyTool.cfg - Runtime imageBuilt by jlink:
java.baseplus needed modules
4 layers, from the top down. Step through them one at a time.
The installer is optional: --type app-image stops at the folder below it.
3Packaging a Non-Modular and a Modular Application
For a normal application on the class path, we point jpackage at a folder of jars and name the main jar. For a modular application, we give it the module path and the main module instead.
Notice that in the non-modular case jpackage still calls jlink, but because it cannot know which modules our jars need, it includes a broad default set. We usually get a smaller and more predictable result by running jdeps and jlink ourselves and passing --runtime-image. In the modular case, jlink knows the module graph and the runtime is trimmed automatically.
4Formats on Each Operating System
Each platform has its own installer formats, and jpackage can produce the common ones for the platform it runs on.
| Platform | Installer types | Notes |
|---|---|---|
| Windows | msi, exe | Needs the WiX Toolset installed |
| macOS | pkg, dmg | Can sign with --mac-sign |
| Linux | deb, rpm | Needs dpkg or rpmbuild tools |
| Any of them | app-image | Unpacked folder, no installer |
The app-image type is useful in two ways: for tools that are simply unzipped, and as a middle step, because we can sign or adjust the folder and then pass it back with --app-image to build the final installer.
5Why There Is No Cross-Packaging
jpackage does not create installers itself; it drives the platform's own tools. On Windows it calls the WiX Toolset to build msi files (check your version for the WiX releases it supports), on macOS it uses Apple's pkgbuild and hdiutil, and on Linux it uses dpkg-deb or rpmbuild. Those tools only exist on their own platform. The launcher is a native executable too, and the runtime image contains native libraries such as libjvm, which differ for each operating system and processor.
So a Windows installer must be built on Windows, and an Apple silicon build on an arm64 Mac. In practice teams use a CI matrix with one runner per target platform, each running the same jpackage command.
6Follow-up questions
How do you pass JVM options to the packaged application?
Use --java-options when running jpackage, once per option, for example --java-options "-Xmx512m". jpackage writes them into the application's .cfg file, and the launcher applies them on every start. The token $APPDIR inside an option is replaced by the application folder at run time, which is useful for paths such as -Dlog.dir=$APPDIR/logs. Default program arguments go in --arguments. Users should not edit the .cfg inside the installation, since an upgrade replaces it.
Can jpackage create an application that updates itself?
No. It builds an installer for one version. Updates need a separate mechanism, such as the operating system's software distribution, a package repository for deb and rpm, or an update framework, combined with a stable upgrade identifier so a new installer replaces the old version.
How large is a typical jpackage application?
A small tool with a trimmed runtime is often 40 to 70 MB installed, most of it the runtime. A JavaFX application adds the JavaFX modules. Using jdeps and jlink with --strip-debug and --no-man-pages keeps it near the lower end.
7Conclusion
In this answer, we saw that jpackage, final since JDK 16, bundles an application, a jlink runtime and a native launcher into a native installer or an unpacked app-image, so users need no separate Java. It handles both class path applications, with --input and --main-jar, and modular ones, with --module-path and --module. It produces msi and exe on Windows, pkg and dmg on macOS and deb and rpm on Linux, and because it drives each platform's own packaging tools and native binaries, it must run on every target platform.
Open with
jpackage is the JDK tool, final since JDK 16, that turns a Java application into a native installer or a self-contained application folder. The output has three parts: a native launcher executable, our application jars with a small configuration file listing the main class and JVM options, and a Java runtime image.
Then, if they want more
The runtime is built with jlink, either automatically or from a runtime we built ourselves and pass with --runtime-image, so users never need to install Java separately and the application controls its own Java version.
It works for both kinds of applications: for class path apps we pass --input with the folder of jars and --main-jar, and for modular apps --module-path and --module. On Windows it produces msi and exe, on macOS pkg and dmg, on Linux deb and rpm, and --type app-image gives an unpacked folder on any of them.
It has to run on each target platform because it does not build installers itself: it drives the platform's tools, like the WiX Toolset on Windows or pkgbuild on macOS, and the launcher and the runtime's native libraries are platform specific. So in practice we build on a CI matrix, one runner per operating system.
JVM options go in with --java-options and end up in the launcher's configuration file.
About this answer
- Last updated
- 12 November 2026
- Versions it names
- Java 16, Java 14, Java 8
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
- Official documentation
- The Java Language Specification, Java SE 21, Java SE 21 API documentation
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "What does the jpackage tool do? Explain what the output contains, which formats it can...": https://scrivio-interview-library.netlify.app/java/modules/e54fee59b9/