Modularity
Learn about modularity in Java 9.
What are the module system addresses?
Project Jigsaw includes both a module system and the ability to use a smaller subset of the JDK.
The classic classpath is still supported, but the module system adds additional functionality.
If you’ve ever developed a large application, you’ve probably experienced an exception caused by a missing jar file or even worse, random errors caused by having more than one version of the same dependency. Up until Java 8, a dependency is not enforced until it is needed at runtime. The module system addresses these problems.
The module system in Java 9+ (9 and above) allows developers to enforce dependencies at compile-time and start-up, which uncovers problems faster and earlier, thus improving software reliability.
The second part of Project Jigsaw is that the JDK has been split into modules using the module system. The core module java.base
will always be included by default. But other modules such as java.sql
and java.xml
will need to be specifically requested. This allows developers to rely on a smaller subset of the JDK and create applications with smaller footprints. This can be useful, for example, in either microservices or small devices with limited memory.
The core of the system is the module-info.java
file that developers define for each module. It consists of a module name, which modules are required, what packages it exports, and what services it uses or provides (if any).
...