Home  >  Article  >  Java  >  What is the JLink tool in Java 9?

What is the JLink tool in Java 9?

WBOY
WBOYforward
2023-09-05 21:57:021316browse

JLink工具在Java 9中是什么?

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.

In

Java 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>

  • module-path is the path to the observable module discovered by the linker. It can be modular JAR files, JMOD files and modules.
  • add-modules Specifies modules to be added to the runtime image. These modules can cause other modules to be added through transitive dependencies.
  • limit-modules Limit the scope of observable modules.
  • the output is the directory containing the generated runtime image.

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

In the above command, the value of

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!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete