Selected Options for the jlink Tool – Java Module System

Selected Options for the jlink Tool

The jlink tool creates a runtime image of an application. A typical command to create a runtime image of an application requires the location of its modules (path), names of modules to include (module_names), and output directory to store the runtime image (output_dir):

Click here to view code image

jlink –module-path
path
 –add-modules
module_names
 –output
output_dir

The runtime image can be executed by the output_dir/java command.

Selected options for the jlink tool are summarized in Table 19.11.

Table 19.11 Selected Options for the jlink Tool

OptionDescription
–module-path
modulepath…

 -p          
modulepath

Specifies the location where the modules for the application can be found. This can be a root directory for the exploded modules with the class files or a directory where the modular JARs can be found. Multiple directories of modules can be specified, separated by a colon (:) on Unix-based platforms and semicolon (;) on Windows platforms.
–add-modules module,…Specifies the modules to include in the generated runtime image. All application modules must be listed. Any standard or JDK modules needed will be automatically included.
–output pathSpecifies the location of the generated runtime image.

Final Remarks on Options for the JDK Tools

It is worth taking a note of how the command options having the short form -p, -m, and -d are specified in different JDK tools. Table 19.12 gives an overview of which long form they represent in which tool and how they are specified.

Table 19.12 Selected Common Shorthand Options for JDK Tools

javacjavajarjdeps
–module-path
path

 -p           
path

–module-path
path

 -p          
path

–module-path
path

 -p          
path

–module-path path (no short form as -p is reserved for –package)
–module
module

 -m     
module

–module
module
[/
mainclass
]
 -m     
module
[/
mainclass
]

–manifest
TXTFILE

 -m       
TXTFILE

–module
module

 -m
module

(no long form)
-d classesDirectory
–describe-module
module

 -d              
module

–describe-module
 -d


(no -d option)