The Java Linker

The Java Linker, commonly referred to as JLink, is a tool that was created to create custom runtime images. This tool collects the appropriate modules along with their dependencies, then optimizes them to create the image. This represents a big change for Java, with the release of Java 9. Before the Java Linker tool, JLink, was available, runtime image creation included initially copying the entire JRE. In a subsequent step, the unused components were removed. In the current Java platform, jlink creates runtime images with only the required modules. jlink is used by the Java Packager to generate an embedded runtime image.

As illustrated in a previous section, recent changes to the Java platform resulted in link time as an optional phase between compile time and runtime. It is in this phase that the appropriate modules are assembled into an optimized runtime image.

JLink is a command-line linking tool that permits the creation of runtime images containing a smaller subset of the JDK modules. This results in smaller runtime images. The following syntax consists of four components—the jlink command, options, the module path, and the output path:

$ jlink <options> ---module-path <modulepath> --output <path>

Here is a list of the options that can be used with the jlink tool along with brief descriptions of each:

The module path tells the linker where to find the modules. The linker will not use exploded modules or JAR/JMOD files.

The output path simply informs the linker where to save the custom runtime image.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset