Pre-General Availability: 2017-05-24


You can use the jlink tool to assemble and optimize a set of modules and their dependencies into a custom runtime image.


jlink [options] --module-path modulepath --add-modules mods --output path

Command-line options separated by spaces. See jlink Options.


The path where jlink discovers observable modules; these can be modular JAR files, JMOD files, or exploded modules.


The names of the modules to add to the runtime image. The jlink tool adds these modules and their transitive dependencies.


The directory that contains the resulting runtime image.


The jlink tool links a set of modules, along with their transitive dependences, to create a custom runtime image.


Developers are responsible for updating their custom runtime images.

Unlike custom runtime images, web-deployed Java applications automatically download application updates from the web as soon as they are available. The Java Auto Update mechanism takes care of updating the JRE to the latest secure version several times every year. Custom runtime images don’t have built-in support for automatic updates.

jlink Options

--add-modules mod [,mod...]
Adds the named modules, mod, to the default set of root modules. The default set of root modules is empty.
--disable-plugin pluginname
Disables the plugin specified.
--endian {little|big}
Specifies the byte order of the generated image; the default value is the format of your system's architecture.
-h or --help
Prints help message.
Suppresses a fatal error when signed modular JARs are linked in the runtime image. The signature-related files of the signed modular JARs aren’t copied to the runtime image.
--launcher command=module or --launcher command=module/main
Specifies the launcher command name for the module or the command name for the module and main class (the module and the main class names are separated by a slash (/)).
--limit-modules mod [,mod...]
Limits the universe of observable modules to those in the transitive closure of the named modules, mod, plus the main module, if any, plus any further modules specified in the --add-modules option.
Lists available plugins, which you can access through command-line options; see jlink Plugins.
-p or --module-path modulepath
Specifies the module path.
Excludes header files.
Excludes man pages.
--output path
Specifies the location of the generated runtime image.
--save-opts filename
Saves jlink options in the specified file.
Prints version information.
Reads options from the specified file.

An options file is a text file that contains the options and values you would typically type in a command prompt. Options may appear on one line or on several lines. You may not specify environment variables for path names. You may comment out lines by prepending a hash symbol (#) to the beginning of the line.

The following is an example of an options file for the jlink command:

#Wed Dec 07 00:40:19 EST 2016
--module-path C:/Java/jdk9/jmods;mlib
--add-modules com.greetings
--output greetingsapp

jlink Plugins


Plugins that aren’t listed in this section aren’t supported and are subject to change.

For plugins requiring a pattern-list, the value is a comma-separated list of elements, each element using one the following forms:

  • glob-pattern
  • glob:glob-pattern
  • regex:regex-pattern
  • @filename
    • filename is the name of a file containing patterns to be used, one pattern per line.

The following plugins are the most useful for developers. For a complete list of all available plugins, run the command jlink --list-plugins.

Optimizes classes by converting Class.forName calls to constant loads.
-c or --compress={0|1|2}[:filter=pattern-list]
Compresses all resources in the output image.
  • Level 0: No compression
  • Level 1: Constant string sharing
  • Level 2: ZIP
An optional pattern-list specifies which files to include.
Specifies files to exclude. Example:


Specifies resources to exclude. Example:


Takes a file hinting to jlink what java.lang.invoke classes to pre-generate. If you don't specify this flag, then jlink generates a default set of classes.
Includes the list of locales; langtag is a BCP 47 language tag. This option supports locale matching as defined in RFC 4647. Ensure that you add the module jdk.localedata when using this option. Example:

--add-modules jdk.localedata --include-locales=en,ja,*-IN

Orders the specified paths in priority order. If @filename is specified, then each element in pattern-list must be an exact match for the paths to be ordered. Example:


Loads, adds, or deletes release properties.
  • file: Loads release properties from the specified file.
  • add: Adds specified properties to the release file. You can specify any number of key=value pairs.
  • del: Deletes the list of keys in the release file key-list.
-G or --strip-debug
Strips debug information from the output image.
Excludes native commands (such as java or java.exe) from the image.
Selects the HotSpot VM in the output image. Default is all.

jlink Examples

The following command creates a runtime image in the directory greetingsapp. It links the module com.greetings whose module definition is contained in the directory mlib. The directory $JAVA_HOME/jmods contains java.base.jmod and the other standard and JDK modules.

jlink --module-path $JAVA_HOME/jmods:mlib --add-modules com.greetings --output greetingsapp

The following command creates a runtime image in the directory compressedrt that is stripped of debug symbols, uses compression to reduce space, and includes French language locale information:

jlink --module-path $JAVA_HOME/jmods --add-modules jdk.localedata --strip-debug --compress=2 --include-locales=fr --output compressedrt

The following example compares the size of the runtime image compressedrt with fr_rt, which isn’t stripped of debug symbols and doesn’t use compression:

jlink --module-path $JAVA_HOME/jmods --add-modules jdk.localedata --include-locales=fr --output fr_rt

du -sh ./compressedrt ./fr_rt
23M     ./compressedrt
36M     ./fr_rt