The JDK's modularization

By now, you have a firm appreciation of Java 9's modularization. The old adage in Java, and other object-oriented programming language, is everything is a class. Now, with Java 9, everything is a module is the new adage. There are three type of modules as explained as follows:

Module type Description
Automatic When a JAR is placed on a new module path, modules are automatically created
Explicit/Named These modules are manually defined by editing the module-info.java file
Unnamed When a JAR is placed on a classpath, unnamed modules are created

When you migrate your applications to Java 9, your application and its libraries become unnamed modules. So, you will need to ensure all the modules are in the module path.

Another thing to be aware of is that your runtime image will not contain the entire JDK. Instead, it will only contain the modules your application requires. It is worth reviewing how the JDK is modularized in Java 9. The following table contains the API specification for the JDK in Java 9:

jdk.accessibility jdk.attach jdk.charsets jdk.compiler
jdk.crypto.cryptoki jdk.crypto.ec jdk.dynalink jdk.editpad
jdk.hotspot.agent jdk.httpserver jdk.incubator.httpclient jdk.jartool
jdk.javadoc jdk.jcmd jdk.jconsole jdk.jdeps
jdk.jdi jdk.jdwp.agent jdk.jlink jdk.jshell
jdk.jsobject jdk.jstatd jdk.localedata jdk.management
jdk.management.agent jdk.naming.dns jdk.naming.rmi jdk.net
jdk.pack jdk.packager.services jdk.policytool jdk.rmic
jdk.scripting.nashorn jdk.sctp jdk.security.auth jdk.security.jgss
jdk.snmp jdk.xml.dom jdk.zipfs

The following table contains the API specification for Java SE in Java 9:

java.activation java.base java.compiler java.cobra
java.datatransfer java.desktop java.instrument java.logging
java.management java.management.rmi java.naming java.prefs
java.rmi java.scripting java.se java.se.ee
java.security.jgss java.security.sasi java.sql java.sql.rowset
java.transaction java.xml java.xml.bind java.xml.crypto
java.xml.ws java.xml.ws java.xml.ws.annotation
Remember, all applications will have access to java.base as it is in the module path by default.

The following table contains the API specification for JavaFX in Java 9:

javafx.base javafx.controls javafx.fxml javafx.graphics
javafx.media javafx.swing javafx.web

There are two additional modules:

  • java.jnlp defines the API for JNLP (Java Network Launch Protocol)
  • java.smartcardio defines the API for the Java Smart Card Input/Output
For details on any of these modules, visit Oracle's Java? Platform, Standard Edition & Java Development Kit Version 9 API Specification website: http://download.java.net/java/jdk9/docs/api/overview-summary.html.