What is Module System in Java 9?



One of the major changes in the Java 9 feature is Module System. Java 9 has introduced the following features as part of the Jigsaw Project.

  • Modular JDK
  • Modular Java Source Code
  • Modular Run-time Images
  • Encapsulate Java Internal APIs
  • Java Platform Module System

One of the main motivations of using the Module System is to provide modular JVM that runs on devices with less available memory. The JVM runs with only those modules and APIs required by the application.

Syntax

module Module-Name {
   requires moduleName;
   exports packageName;
}

The Modular JAR file contains an additional module descriptor. In this module descriptor, the dependencies of other modules have expressed through "requires" statements. The "exports" statements control which packages have access to other modules.


Advertisements