Java 9 Modules


Oracle corp has postponed Java 9 release from March 2017 to September 2017. As we know, Java SE 8 came with three big new features (plus few more enhancements and new features).

  • Lambda Expressions
  • Stream API
  • Date API
Java SE 9: Jigsaw Project

Jigsaw project is going to introduce completely new concept of Java SE 9: Java Module System.

It is very big and prestigious project from Oracle Corp in Java SE 9 release. Initially, they have started this project as part of Java SE 7 Release. However, with huge changes, it’s postponed to Java SE 8 then again postponed. Now it is about to release with Java SE 9 in September 2017.

Problems of Current Java System?

In this section, we will discuss “Why we need Java SE 9 Module System” that means the problems of Current Java System.

Java SE 8 or earlier systems have following problems in developing or delivering Java Based applications.

  • As JDK is too big, it is a bit tough to scale down to small devices. Java SE 8 has introduced 3 types of compact profiles to solve this problem: compact1, compact2, and compact3. But it does not solve this problem.
  • JAR files like rt.jar etc are too big to use in small devices and applications.
  • As JDK is too big, our applications or devices are not able to support better Performance.
  • There is no Strong Encapsulation in the current Java System because “public” access modifier is too open. Everyone can access it.
  • As JDK, JRE is too big, it is hard to Test and Maintain applications.
  • As the public is too open, They are not to avoid the accessing of some Internal Non-Critical APIs like sun.*, *.internal.* etc.
  • As User can access Internal APIs too, Security is also big issue.
  • Application is too big.
  • Its a bit tough to support Less Coupling between components.

To solve all these problems, Oracle Corp is going to release Java Module system in Java SE 9 Release.

Advantages of Java SE 9 Module System

Java SE 9 Module System is going to provide the following benefits

  • As Java SE 9 is going to divide JDK, JRE, JARs etc, into smaller modules, we can use whatever modules we want. So it is very easy to scale down the Java Application to Small devices.
  • Ease of Testing and Maintainability.
  • Supports better Performance.
  • As public is not just public, it supports very Strong Encapsulation. (Don’t worry its a big concept. we will explore it with some useful examples soon).
  • We cannot access Internal Non-Critical APIs anymore.
  • Modules can hide unwanted and internal details very safely, we can get better Security.
  • Application is too small because we can use only what ever modules we want.
  • Its easy to support Less Coupling between components.
  • Its easy to support Single Responsibility Principle (SRP).

We will explore all these concepts one by one soon.

As of today, “jmods” contains 95 modules. It may increase in the final release.
“jmods” folder is available at ${JAVA_HOME}/jmods. These are known as JDK Modules.

What is Java 9 Module?

A Module is a self-describing collection of Code, Data, and some Resources. It is a set of related Packages, Types (classes, abstract classes, interfaces etc) with Code & Data and Resources.

Each Module contains only a set of related code and data to support Single Responsibility (Functionality) Principle (SRP).

Mother of Java 9 Module System

As of now, Java 9 Module System has 95 modules in Early Access JDK. Oracle Corp has separated JDK jars and Java SE Specifications into two set of Modules.

  • All JDK Modules starts with “jdk.*”
  • All Java SE Specifications Modules starts with “java.*”

Java 9 Module System has a “java.base” Module. It’s known as Base Module. It’s an Independent module and does NOT dependent on any other modules. By default, all other Modules dependent on this module.

That’s why “java.base” Module is also known as The Mother of Java 9 Modules.

It’s default module for all JDK Modules and User-Defined Modules.

journaldev is optimized for learning.© journaldev .
All Right Reserved and you agree to have read and accepted our term and condition