Why rt.jar is missing from Jdk9?
This is one of the most common question comes to our mind when we see the JDK 9 structure. Previous to JDK 9, Java was having all classes and packages into one single jar I.e. rt.jar aka Java Runtime. Which have 1000+ classes and packages. Rt.jar helps to execute the source code. It provides native support to the application. Let’s get understand with the example if you have written a program just to add two values and print the result.
Class example {
public static void main(String args){
int a= 10;
int b=20;
int c=a+b;
System.out.print(“Result ”+c);
}
}
For example, to execute the above program on a machine that can be a PC, mobile device, calculator powered by Java must have this rt.jar and it’s huge in size. Other than PC these devices have very limited space and memory as they are developed for some specific purpose.
So Java 9 came up with a new approach that is modular Java, with this approach they break this rt.jar into nearly 100 modules and each module have its own specific purpose and functionality.
The biggest advantage of this approach is smaller size specific JDK can be pushed into specific devices i.e. customisation in JDK is available and easy to maintain.
If we want to develop a device that can do some specific tasks like calculations then we need to make a customised JDK with the related modules only. Because no need to serve all the 1000+ classes and packages which will be unused here. This is how modularity is going to change the future of Java powered devices and it is also going to open a lot of other possibilities as well.
Comments
Post a Comment