JPACKAGE(1)

πŸ“¦ version 23.0.2.0, in opensuse-leap 16.0

πŸ’… jpackage(1) β€” JDK Commands, but make it cute

🌸 NAME

jpackage β€” tool for packaging self-contained Java applications. Periodt.


✨ SYNOPSIS

jpackage [options]
  • options β€” Command-line options separated by spaces. See jpackage Options.

πŸ¦‹ DESCRIPTION

Okay so picture this, bestie: jpackage takes a Java application and a Java runtime image as input, and produces a Java application image that includes all the necessary dependencies. Iconic behavior, honestly.

It can produce a native package in a platform-specific format, such as an exe on Windows or a dmg on macOS. Each format must be built on the platform it runs on β€” there is no cross-platform support, no cap. The tool has options that allow packaged applications to be customized in various ways. Slay.

Real talk: each format must be built on the platform it runs on. There is no cross-platform support. Not me pretending otherwise πŸ’€.

πŸŽ€ JPACKAGE OPTIONS

πŸ’– Generic Options:

  • @filename β€” Read options from a file. This option can be used multiple times.
  • --type or -t type β€” The type of package to create. Valid values are: {"app-image", "exe", "msi", "rpm", "deb", "pkg", "dmg"}. If this option is not specified a platform dependent default type will be created.
  • --app-version version β€” Version of the application and/or package.
  • --copyright copyright β€” Copyright for the application.
  • --description description β€” Description of the application.
  • --help or -h β€” Print the usage text with a list and description of each valid option for the current platform to the output stream, and exit.
  • --icon path β€” Path of the icon of the application package (absolute path or relative to the current directory).
  • --name or -n name β€” Name of the application and/or package.
  • --dest or -d destination β€” Path where generated output file is placed (absolute path or relative to the current directory). Defaults to the current working directory.
  • --temp directory β€” Path of a new or empty directory used to create temporary files (absolute path or relative to the current directory). If specified, the temp dir will not be removed upon the task completion and must be removed manually. If not specified, a temporary directory will be created and removed upon the task completion. So if you pass this one, bestie, cleanup is on you 🫢
  • --vendor vendor β€” Vendor of the application.
  • --verbose β€” Enables verbose output.
  • --version β€” Print the product version to the output stream and exit.

🌈 Options for creating the runtime image:

  • --add-modules module-name [,module-name...] β€” A comma (",") separated list of modules to add. This module list, along with the main module (if specified) will be passed to jlink as the --add-module argument. If not specified, either just the main module (if --module is specified), or the default set of modules (if --main-jar is specified) are used. This option can be used multiple times.
  • --module-path or -p module-path [,module-path...] β€” A File.pathSeparator separated list of paths. Each path is either a directory of modules or the path to a modular jar, and is absolute or relative to the current directory. This option can be used multiple times.
  • --jlink-options options β€” A space separated list of options to pass to jlink. If not specified, defaults to "--strip-native-commands --strip-debug --no-man-pages --no-header-files". This option can be used multiple times.
  • --runtime-image directory β€” Path of the predefined runtime image that will be copied into the application image (absolute path or relative to the current directory). If --runtime-image is not specified, jpackage will run jlink to create the runtime image using options specified by --jlink-options.

πŸš€ Options for creating the application image:

  • --input or -i directory β€” Path of the input directory that contains the files to be packaged (absolute path or relative to the current directory). All files in the input directory will be packaged into the application image.
  • --app-content additional-content [,additional-content...] β€” A comma separated list of paths to files and/or directories to add to the application payload. This option can be used more than once.

🧚 Options for creating the application launcher(s):

  • --add-launcher name=path β€” Name of launcher, and a path to a Properties file that contains a list of key, value pairs (absolute path or relative to the current directory). The keys "module", "main-jar", "main-class", "description", "arguments", "java-options", "app-version", "icon", "launcher-as-service", "win-console", "win-shortcut", "win-menu", "linux-app-category", and "linux-shortcut" can be used. These options are added to, or used to overwrite, the original command line options to build an additional alternative launcher. The main application launcher will be built from the command line options. Additional alternative launchers can be built using this option, and this option can be used multiple times to build multiple additional launchers.
  • --arguments arguments β€” Command line arguments to pass to the main class if no command line arguments are given to the launcher. This option can be used multiple times.
  • --java-options options β€” Options to pass to the Java runtime. This option can be used multiple times.
  • --main-class class-name β€” Qualified name of the application main class to execute. This option can only be used if --main-jar is specified.
  • --main-jar main-jar β€” The main JAR of the application; containing the main class (specified as a path relative to the input path). Either --module or --main-jar option can be specified but not both.
  • --module or -m module-name[/main-class] β€” The main module (and optionally main class) of the application. This module must be located on the module path. When this option is specified, the main module will be linked in the Java runtime image. Either --module or --main-jar option can be specified but not both.

🧚 Platform dependent option for creating the application launcher:

πŸͺŸ Windows platform options (available only when running on Windows):

  • --win-console β€” Creates a console launcher for the application, should be specified for application which requires console interactions.

🍎 macOS platform options (available only when running on macOS):

  • --mac-package-identifier identifier β€” An identifier that uniquely identifies the application for macOS. Defaults to the main class name. May only use alphanumeric (A-Z,a-z,0-9), hyphen (-), and period (.) characters.
  • --mac-package-name name β€” Name of the application as it appears in the Menu Bar. This can be different from the application name. This name must be less than 16 characters long and be suitable for displaying in the menu bar and the application Info window. Defaults to the application name.
  • --mac-package-signing-prefix prefix β€” When signing the application package, this value is prefixed to all components that need to be signed that don't have an existing package identifier.
  • --mac-sign β€” Request that the package or the predefined application image be signed.
  • --mac-signing-keychain keychain-name β€” Name of the keychain to search for the signing identity. If not specified, the standard keychains are used.
  • --mac-signing-key-user-name name β€” Team or user name portion in Apple signing identities.
  • --mac-app-store β€” Indicates that the jpackage output is intended for the Mac App Store.
  • --mac-entitlements path β€” Path to file containing entitlements to use when signing executables and libraries in the bundle.
  • --mac-app-category category β€” String used to construct LSApplicationCategoryType in application plist. The default value is "utilities".

🎁 Options for creating the application package:

  • --about-url url β€” URL of the application's home page.
  • --app-image directory β€” Location of the predefined application image that is used to build an installable package (on all platforms) or to be signed (on macOS) (absolute path or relative to the current directory).
  • --file-associations path β€” Path to a Properties file that contains list of key, value pairs (absolute path or relative to the current directory). The keys "extension", "mime-type", "icon", and "description" can be used to describe the association. This option can be used multiple times.
  • --install-dir path β€” Absolute path of the installation directory of the application (on macOS or linux), or relative sub-path of the installation directory such as "Program Files" or "AppData" (on Windows).
  • --license-file path β€” Path to the license file (absolute path or relative to the current directory).
  • --resource-dir path β€” Path to override jpackage resources (absolute path or relative to the current directory). Icons, template files, and other resources of jpackage can be over-ridden by adding replacement resources to this directory.
  • --runtime-image path β€” Path of the predefined runtime image to install (absolute path or relative to the current directory). Option is required when creating a runtime installer.
  • --launcher-as-service β€” Request to create an installer that will register the main application launcher as a background service-type application.

🌍 Platform dependent options for creating the application package:

πŸͺŸ Windows platform options (available only when running on Windows):

  • --win-dir-chooser β€” Adds a dialog to enable the user to choose a directory in which the product is installed.
  • --win-help-url url β€” URL where user can obtain further information or technical support.
  • --win-menu β€” Request to add a Start Menu shortcut for this application.
  • --win-menu-group menu-group-name β€” Start Menu group this application is placed in.
  • --win-per-user-install β€” Request to perform an install on a per-user basis.
  • --win-shortcut β€” Request to create a desktop shortcut for this application.
  • --win-shortcut-prompt β€” pops up a lil dialog so the user gets to pick whether the installer makes shortcuts for them πŸŽ€
  • --win-update-url url β€” the URL where your app's available update info lives πŸ”—
  • --win-upgrade-uuid id β€” the UUID tied to upgrades for this package πŸ†”

🐧 Linux platform options (only a thing when you're running on Linux)

  • --linux-package-name name β€” the name for the Linux package β€” defaults to the application name, slay ✨
  • --linux-deb-maintainer email-address β€” who's maintaining the .deb bundle, put your email bestie πŸ’Œ
  • --linux-menu-group menu-group-name β€” the menu group this application gets placed in πŸ—‚οΈ
  • --linux-package-deps β€” the required packages or capabilities for the application, iykyk πŸ“¦
  • --linux-rpm-license-type type β€” type of the license (that's the "License: value" of the RPM .spec) πŸͺͺ
  • --linux-app-release release β€” the Release value of the RPM <name>.spec file, or the Debian revision value of the DEB control file 🏷️
  • --linux-app-category category-value β€” the Group value of the RPM /.spec file, or the Section value of the DEB control file πŸ—ƒοΈ
  • --linux-shortcut β€” literally just creates a shortcut for the application, periodt πŸ’…

🍎 macOS platform options (only when you're running on macOS)

  • --mac-dmg-content additional-content [,additional-content...] β€” includes all the referenced content in the dmg πŸ’Ώ this one can be used more than once, so go off.

🌈 JPACKAGE EXAMPLES 🌈

Okay bestie, here's your cheat sheet β€” generate an application package that suits the host system:

For a modular application:

jpackage -n name -p modulePath -m moduleName/className

For a non-modular application:

jpackage -i inputDir -n name \
    --main-class className --main-jar myJar.jar

From a pre-built application image:

jpackage -n name --app-image appImageDir

Now generate an application image:

For a modular application:

jpackage --type app-image -n name -p modulePath \
    -m moduleName/className

For a non-modular application:

jpackage --type app-image -i inputDir -n name \
    --main-class className --main-jar myJar.jar

Wanna hand your own options over to jlink? Then run jlink separately, like this:

jlink --output appRuntimeImage -p modulePath \
    --add-modules moduleName \
    --no-header-files [<additional jlink options>...]
jpackage --type app-image -n name \
    -m moduleName/className --runtime-image appRuntimeImage

Generate a Java runtime package:

jpackage -n name --runtime-image <runtime-image>

And to sign the predefined application image (on macOS):

jpackage --type app-image --app-image <app-image> \
    --mac-sign [<additional signing options>...]
Note: the only additional options that are permitted in this mode are the set of additional mac signing options and --verbose. That's it, icon behavior only, no extras 🫢

πŸŽ€ JPACKAGE RESOURCE DIRECTORY πŸŽ€

So here's the tea: icons, template files, and other resources of jpackage can be over-ridden by adding replacement resources to this directory. jpackage will lookup files by specific names in the resource directory. Very "name on the list" energy πŸ’…

🌸 Resource directory files considered only when running on Linux

  • <launcher-name>.png β€” application launcher icon. The default resource is JavaApp.png πŸ–ΌοΈ
  • <launcher-name>.desktop β€” a desktop file to be used with the xdg-desktop-menu command. It's considered with application launchers registered for file associations and/or that have an icon. The default resource is template.desktop πŸ“„

🌸 Resource directory files considered only when building Linux DEB/RPM installer

  • <package-name>-<launcher-name>.service β€” systemd unit file for an application launcher registered as a background service-type application. The default resource is unit-template.service βš™οΈ

🌸 Resource directory files considered only when building Linux RPM installer

  • <package-name>.spec β€” RPM spec file. The default resource is template.spec πŸ“

🌸 Resource directory files considered only when building Linux DEB installer

  • control β€” control file. The default resource is template.control πŸ—‚οΈ
  • copyright β€” copyright file. The default resource is template.copyright ©️
  • preinstall β€” pre-install shell script. The default resource is template.preinstall 🐚
  • prerm β€” pre-remove shell script. The default resource is template.prerm 🐚
  • postinstall β€” post-install shell script. The default resource is template.postinstall 🐚
  • postrm β€” post-remove shell script. The default resource is template.postrm 🐚

🌸 Resource directory files considered only when running on Windows

  • <launcher-name>.ico β€” application launcher icon. The default resource is JavaApp.ico πŸ–ΌοΈ
  • <launcher-name>.properties β€” properties file for the application launcher executable. The default resource is WinLauncher.template πŸ“„

🌸 Resource directory files considered only when building Windows MSI/EXE installer

  • <application-name>-post-image.wsf β€” a Windows Script File (WSF) to run after building the application image πŸͺŸ
  • main.wxs β€” main WiX project file. The default resource is main.wxs 🧩
  • overrides.wxi β€” overrides WiX project file. The default resource is overrides.wxi 🧩
  • service-installer.exe β€” service installer executable. Considered if some application launchers are registered as background service-type applications βš™οΈ
  • <launcher-name>-service-install.wxi β€” service installer WiX project file. Considered if some application launchers are registered as background service-type applications. The default resource is service-install.wxi βš™οΈ
  • <launcher-name>-service-config.wxi β€” service installer WiX project file. Considered if some application launchers are registered as background service-type applications. The default resource is service-config.wxi βš™οΈ
  • InstallDirNotEmptyDlg.wxs β€” WiX project file for the installer UI dialog checking the installation directory doesn't exist or is empty. The default resource is InstallDirNotEmptyDlg.wxs πŸ’¬
  • ShortcutPromptDlg.wxs β€” WiX project file for the installer UI dialog configuring shortcuts. The default resource is ShortcutPromptDlg.wxs πŸ’¬
  • bundle.wxf β€” WiX project file with the hierarchy of components of the application image 🧩
  • ui.wxf β€” WiX project file for installer UI πŸ’¬

🌸 Resource directory files considered only when building Windows EXE installer

  • WinInstaller.properties β€” properties file for the installer executable. The default resource is WinInstaller.template πŸ“„
  • <package-name>-post-msi.wsf β€” a Windows Script File (WSF) to run after building the embedded MSI installer for the EXE installer πŸͺŸ

🌸 Resource directory files considered only when running on macOS

  • <launcher-name>.icns β€” application launcher icon. The default resource is JavaApp.icns πŸ–ΌοΈ
  • Info.plist β€” application property list file. The default resource is Info-lite.plist.template πŸ“„
  • Runtime-Info.plist β€” Java Runtime property list file. The default resource is Runtime-Info.plist.template πŸ“„
  • <application-name>.entitlements β€” signing entitlements property list file. The default resource is sandbox.plist πŸ”

🌸 Resource directory files considered only when building macOS PKG/DMG installer

  • <package-name>-post-image.sh β€” shell script to run after building the application image 🐚

🌸 Resource directory files considered only when building macOS PKG installer

  • uninstaller β€” uninstaller shell script. Considered if some application launchers are registered as background service-type applications. The default resource is uninstall.command.template πŸ—‘οΈ
  • preinstall β€” pre-install shell script. The default resource is preinstall.template 🐚
  • postinstall β€” post-install shell script. The default resource is postinstall.template 🐚
  • services-preinstall β€” pre-install shell script for the services package. Considered if some application launchers are registered as background service-type applications. The default resource is services-preinstall.template βš™οΈ
  • services-postinstall β€” post-install shell script for the services package. Considered if some application launchers are registered as background service-type applications. The default resource is services-postinstall.template βš™οΈ
  • <package-name>-background.png β€” background image. The default resource is background_pkg.png πŸŒ„
  • <package-name>-background-darkAqua.png β€” dark background image. The default resource is background_pkg.png πŸŒƒ
  • product-def.plist β€” package property list file. The default resource is product-def.plist πŸ“„
  • <package-name>-<launcher-name>.plist β€” launchd property list file for an application launcher registered as a background service-type application. The default resource is launchd.plist.template βš™οΈ

🌸 Resource directory files considered only when building macOS DMG installer

  • <package-name>-dmg-setup.scpt β€” setup AppleScript script. The default resource is DMGsetup.scpt 🍎
  • <package-name>-license.plist β€” license property list file. The default resource is lic_template.plist πŸ“œ
  • <package-name>-background.tiff β€” background image. The default resource is background_dmg.tiff πŸŒ„
  • <package-name>-volume.icns β€” volume icon. The default resource is JavaApp.icns πŸ’Ώ

That's the whole page bestie, you ate that 🫢 This one's from JDK 23, dated 2024, and it's JPACKAGE(1) β€” go make something iconic with it, mwah πŸ’–βœ¨πŸ‘‘

πŸ“¦ where this page comes from