
- Java Tutorial
- Java - Home
- Java - Overview
- Java - Environment Setup
- Java - Basic Syntax
- Java - Object & Classes
- Java - Constructors
- Java - Basic Datatypes
- Java - Variable Types
- Java - Modifier Types
- Java - Basic Operators
- Java - Loop Control
- Java - Decision Making
- Java - Numbers
- Java - Characters
- Java - Strings
- Java - Arrays
- Java - Date & Time
- Java - Regular Expressions
- Java - Methods
- Java - Files and I/O
- Java - Exceptions
- Java - Inner classes
- Java Object Oriented
- Java - Inheritance
- Java - Overriding
- Java - Polymorphism
- Java - Abstraction
- Java - Encapsulation
- Java - Interfaces
- Java - Packages
- Java Advanced
- Java - Data Structures
- Java - Collections
- Java - Generics
- Java - Serialization
- Java - Networking
- Java - Sending Email
- Java - Multithreading
- Java - Applet Basics
- Java - Documentation
- Java Useful Resources
- Java - Questions and Answers
- Java - Quick Guide
- Java - Useful Resources
- Java - Discussion
- Java - Examples
What is the purpose of using JLink in Java 9?
The main purpose of the JLink feature is to create our own Customized JRE. Usually, we run a program with the default JRE that has been provided by Oracle Corporation with 214 MB of size.
For instance, a user wants to print a simple "Hello World" message as shown below
public class HelloWorldModuleTest { public static void main(String args[[]) { System.out.println("Hello World!"); } }
To run the above program of 1 KB size, we need 4 – 5 classes like String, System, Object, and HelloWorldModuleTest.class files. Then why do we need to load 214 MB of JRE using default JRE? It's a waste of memory and not suitable for any IoT devices because these small devices can't hold hundreds of memory.
We need to create our own Customized JRE using JLink in the below command.
jlink –module-path out –add-modules {add modules} –output {jre name}
JLink is a powerful feature that has implemented with the help of JPMS to reduce the size of JRE. JLink comes with the concept of Compress, where we specify the compress level while executing the JLink command. JLink also provides an option called Launcher that enables the user to execute programs from anywhere on the machine by just calling program name from command-line prompt without specifying java or javac.
- Related Articles
- What is the JLink tool in Java 9?
- What is the purpose of using Optional.ifPresentOrElse() method in Java 9?
- What is the purpose of using a dumpStack() method in Java?
- What is the purpose of interfaces in java?
- What is the purpose of System class in Java?
- What is the purpose of Runtime class in Java?
- What is the purpose of private constructor in Java?
- What is the purpose of a constructor in java?
- What is the purpose of Process class in Java?
- What is the purpose of a default constructor in Java?
- What is the purpose of overriding a finalize() method in Java?
- What is the purpose of the flush() method of the BufferedWriter class in java?
- What is the importance of REPL in Java 9?
- What is the purpose of ‘is’ operator in C#?
- What is the purpose of VOLUME in Dockerfile?
