☰ See All Chapters |
Java Module System
Showing essential features and properties by hiding internal things we can achieve abstraction. But sometimes while exposing essential features we may have to expose sensitive data. As an example, in the below project we have to provide Util feature from com.java4coding.util package to the clients. But security feature from com.java4coding.security package should not be accessible form outside. In this project Util class is using Security class, so we have to make Security class public and this Security class is now accessible from outside. When this project is delivered to clients in the form of JAR, client can access both Security and Util packages.
Solution to above shortcoming is Java Module System. Java 9 introduced Java Platform Module System (JPMS) which has made java abstraction to reach next level.
What is module?
A large enterprise e-commerce application can consist of following modules:
Account Module
Shipment Module
Inventory Module
Logging Module
Error Handling Module etc…
These modules can be separate individual applications with their sub modules. So now you have understood what a module is. In java 9, module is not the same as we seen in above example. When a module thought comes in mind everybody thinks as a separate unit or an excerpt. This is true in java 9 only when we include module descriptor in that. So what is module descriptor? Please follow our next tutorial to read about module descriptor.
All Chapters