// Tutorial //

Java 9 Modules

Published on August 3, 2022
Default avatar
By Rambabu Posa
Developer and author at DigitalOcean.
Java 9 Modules

While we believe that this content benefits our community, we have not yet thoroughly reviewed it. If you have any suggestions for improvements, please let us know by clicking the “report an issue“ button at the bottom of the tutorial.

Java 9 modules are one of the biggest change in the structure of java. Here I am going to give a brief high level introduction about “Java 9 Module System”.

Java 9 Modules

We will look into following topics about java 9 modules system.

  1. Introduction
  2. Java SE 9: Jigsaw Project
  3. Problems of Current Java System?
  4. Advantages of Java SE 9 Module System
  5. Compare JDK 8 and JDK 9
  6. What is Java 9 Module?
  7. Mother of Java 9 Module System
  8. Compare Java 8 and Java 9 Applications


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).

  1. Lambda Expressions
  2. Stream API
  3. Date API

In the same way, Java SE 9 is coming with three big features (plus few more enhancements and new features):

  1. Java Module System (Jigsaw Project)
  2. Java REPL
  3. Milling Project Coin

In this post, we will discuss Oracle Jigsaw project basics.

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. Main Goals of Jigsaw Project:

  • The Modular JDK As we know, Current JDK system is too big. So they have decided to divide JDK itself into small modules to get a number of benefits (We will discuss them soon in the coming sections).- Modular Source Code Current source code jar files are too big, especially rt.jar is too big right. So they are going to divide Java Source code into smaller modules.- Modular Run-Time Images The main goal of this Feature is “Restructure the JDK and JRE run-time images to accommodate modules”.- Encapsulate Most Internal APIs The main goal of this feature is “Make most of the JDK’s internal APIs inaccessible by default but leave a few critical, widely-used internal APIs accessible”.- Java Platform Module System The main goal of this Feature is “Allowing the user to create their modules to develop their applications”.- jlink: The Java Linker The main goal of this jlink Tool is “Allowing the user to create executable to their applications”.

If you don’t understand these things clearly, do NOT worry. We will discuss these concepts in-depth with some useful examples in the coming sections and also in my coming posts.

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.

Compare JDK 8 and JDK 9

We know what a JDK software contains. After installing JDK 8 software, we can see a couple of directories like bin, jre, lib etc in Java Home folder. However, Oracle Corp has changed this folder structure a bit differently as shown below. java 9 modules JDK 8 Folder Structure: java 8 folder structure JDK 9 Folder Structure: java module system Here JDK 9 does NOT contain JRE. In JDK 9, JRE is separated into a separate distribution folder. JDK 9 software contains a new folder “jmods”. It contains a set of Java 9 Modules as shown below. In JDK 9, No rt.jar and No tools.jar jmods folder, java modules NOTE:- 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). java 9 modules system The main goal of Java 9 Module System is to support Modular Programming in Java. We will discuss on “What is a Module Descriptor” and “How to develop Java Modules” in my coming posts.

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.

Compare Java 8 and Java 9 Applications

We have already developed many Java applications using Java 5, 6,7, or 8. We know how a Java 8 or earlier applications looks like and what it contains. In brief, I have depicted a Java 8 applications in a diagram as shown below: java 8 application module In a Java 8 or earlier applications, Top level component a Package. It groups a set related to types into a group. It also contains a set of resources. Java 9 Applications does not have much difference with this. It just introduced a new component called “Module”, which is used to group a set of related Packages into a group. And one more new component that Module Descriptor (“module-info.java”). That’s it. Rest of the application is same as earlier versions of applications as shown below. java 9 application module system Like Java 8 applications have Packages as a Top level components, Java 9 applications have Module as Top Level components. NOTE:- Each Java 9 Module have one and only one Module and one Module Descriptor. Unlike Java 8 Packages, We cannot create multiple modules into a single Module. In brief I can say a Java 9 Module contains the following main components:

  • One Module
  • Module Name
  • Module Descriptor
  • Set of Packages
  • Set of Types and Resources

Here Resources may be module-info.java (Module Descriptor) or any other properties or XML. We have discussed too much theory in this post. I think that is enough to understand the basics of Java 9 Module system. We will start some basic Module development in my coming post. I will discuss some more Theory concepts or Java 9 Module System terminology as and when required. That’s it all about “Introduction to Java 9 Module System” topic. We will discuss some more Java SE 9 Module System concepts in my coming posts. Please drop me a comment if you like my post or have any issues/suggestions/type errors. Thank you for reading my tutorials. Happy Java SE 9 Learning! Reference: Project Jigsaw

If you’ve enjoyed this tutorial and our broader community, consider checking out our DigitalOcean products which can also help you achieve your development goals.

Learn more here

About the authors
Default avatar
Developer and author at DigitalOcean.

Still looking for an answer?

Was this helpful?

Thank u so much for the post. It is very helping. Another thing I would like to add here that grammatical or typo error hardly matters for people who are here to learn Java 9. This should not be a problem for anyone as long as they are interested in technical things.

- Abha

    This article is so descriptive thank you.

    - bulent

      Awesome.! Great step by step comparison of Java 8 and Java 9 which focus on core differences. Thanks Pankaj

      - Rakesh Kumar

        “That’s why “java.base” Module is also known as The Mother of Java 9 Modules.” I call it MOM (Mother-of-Modules). Great article, thanks!

        - Collin

          Excellent post. Thank you.

          - Hiten

            Rambabu, I don’t mean to be rude, but I struggled to read your article. As a native English speaker, the lack of use of the definite and indefinite article (i…e. “the”, “a” and “an”) made some parts confusing. Your grasp of English is far greater than my grasp of any other language, but using articles (i.e. “the”, “a” and “an”) more will enhance it even more. Many thanks for taking the time to write such useful pieces though.

            - John M

              awesome post. thanks typo -> Module is also know as

              - irfan

                Excellent post! Typo -> Spelling of Modules (Mdoules).

                - Nitin

                  Good post. Very Informative. Thanks.

                  - gaurav

                    Excellent Job. Very much informative. Awaiting for the other posts.

                    - Neel