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

What is the JLink tool in Java 9?

WBOY
Release: 2023-09-05 21:57:02
forward
1404 people have browsed it

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>
Copy after login

  • 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>
Copy after login

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!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template