JLink is a new linker tool for creating our own custom JRE. Usually, we can use the default JRE provided by Oracle to run our program. If we need to create our own JRE, then we can use this tool. The JLink tool can help create your own JRE that contains only the classes required to run your application. It can reduce the size of developed APIs and reduce dependencies on using a full JRE.
InJava 9, we have a new phase between compiling code and executing code, which is link time. Link time is an optional phase between compile time and run time.
Command to create a custom JRE<strong>jlink --module-path --add-modules --limit-modules --output</strong>
<strong>jlink --module-path $JAVA_HOME/jmods:mlib --add-modules com.greetings --output greetingsapp</strong>
module-path is the path to the directory containing the packaged module. JAVA_HOME/jmods is a directory containing java.base.jmod, other standard and JDK modules. The mlib directory on the module path contains the components of module com.greetings.
The above is the detailed content of What is the JLink tool in Java 9?. For more information, please follow other related articles on the PHP Chinese website!