Java 9 : What is Project Jigsaw ?

Project Jigsaw : Points to Remember

  1. It is introducded in Java 9.
  2. Its main aim is to modularize the Java SE Platform.
  3. This will modularize the JDK, and we can use only those modules that we need instead of the full JDK installation.
  4. Scale platform to run on smaller applications and devices.

Also Read

Design Implementations of Project Jigsaw.

New java commands related to Project Jigsaw added are the following

    --module-path <module path>...
                  A : separated list of directories, each directory
                  is a directory of modules.
    --upgrade-module-path <module path>...
                  A : separated list of directories, each directory
                  is a directory of modules that replace upgradeable
                  modules in the runtime image
    -m <module>[/<mainclass>]
    --module <modulename>[/<mainclass>]
                  the initial module to resolve, and the name of the main class
                  to execute if not specified by the module
    --add-modules <modulename>[,<modulename>...]
                  root modules to resolve in addition to the initial module.
                  <modulename> can also be ALL-DEFAULT, ALL-SYSTEM,
                  ALL-MODULE-PATH.
    --limit-modules <modulename>[,<modulename>...]
                  limit the universe of observable modules
    --list-modules [<modulename>[,<modulename>...]]
                  list the observable modules and exit

What are Modules ?

Firstly, let's see what is a module in Java.

A module is a named, self-describing collection of code and data. Its code is organized as a set of packages containing types, i.e., Java classes and interfaces; its data includes resources and other kinds of static information.

  1. All the Java code will be a part of some java module.
  2. All Java base modules will have their name starting with string java.. These are also called as Java Standard Modules.
  3. All other Java packages will be part of Java JDK and will have module names starting from jdk.. These are also called as Java Non Statndard Modules.

All the Standard Modules are shown with orange color, and all Non-Standard modules are shown in Blue color Java Module Structure


Read more about Java Module Structure


Now let's run the command

java --list-modules

This will list all the modules. Some of the many modules will be

java.compiler@9-ea
java.httpclient@9-ea
java.instrument@9-ea
java.jnlp@9-ea
java.logging@9-ea
java.se@9-ea
java.se.ee@9-ea
java.security.jgss@9-ea
java.security.sasl@9-ea
jdk.compiler@9-ea
jdk.crypto.ec@9-ea
jdk.jartool@9-ea
jdk.javadoc@9-ea
jdk.jconsole@9-ea
jdk.jlink@9-ea
jdk.jshell@9-ea

Above shown list is just a subsut of modules and not the complete list of modules.(Just to show what the output will look like)

"

No comments:

Powered by Blogger.