- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is the JLink tool in Java 9?
JLink is a new linker tool that has been used to create our own customized JRE. Usually, we can run our program using default JRE provided by Oracle. If we need to create our own JRE then use this tool. JLink tool can help to create its own JRE with only the required class to run the application. It can reduce the size of the API developed and the dependency of using full JRE.
In Java 9, we have a new phase between compiling the code and its execution link time. Link time is an optional phase between the phases of compile-time and runtime.
Command to create custom JRE
jlink --module-path --add-modules --limit-modules --output
- module-path is the path where observable modules have discovered by the linker. It can be modular JAR files, JMOD files, and modules.
- add-modules names the modules to add to the run-time image, these modules can, via transitive dependencies, cause additional modules to be added.
- limit-modules limits the universe of observable modules.
- the output is the directory that contains the resulting run-time image.
jlink --module-path $JAVA_HOME/jmods:mlib --add-modules com.greetings --output greetingsapp
In the above command, the value to module-path is a PATH of directories containing the packaged modules. JAVA_HOME/jmods is a directory containing java.base.jmod, other standards, and JDK modules. The directory mlib on the module path containing the artifact for module com.greetings.
- What is the purpose of using JLink in Java 9?
- What is the importance of jdeps tool in Java 9?
- What is the use of the jdeprscan tool in Java 9?
- What is the importance of the jcmd tool in Java 9?
- How JShell tool works internally in Java 9?
- What is the importance of REPL in Java 9?
- What is Module System in Java 9?
- What is Project Jigsaw in Java 9?
- What is Variable Handle in Java 9?
- What is maven automatic build tool in Java eclipse projects?
- What is the use of underscore keyword in Java 9?
- What is the importance of jmod format in Java 9?
- What is the use of the Cleaner class in Java 9?
- What is the use of the Optional.stream() method in Java 9?
- What is the use of the toEpochSecond() method in Java 9?