Java Platform Module System

Also called JPMS, Jigsaw, or "Java 9 Module System". See the Wikipedia entry: https://en.wikipedia.org/wiki/Java_Platform_Module_System

Java 9 introduced the module system. See OpenJDK's command-line "quick start" guide for an in depth explanation.

Contents

Links to Documentation and Tools

IntelliJ: https://www.jetbrains.com/help/idea/getting-started-with-java-9-module-system.html

Eclipse: https://help.eclipse.org/2019-09/topic/org.eclipse.jdt.doc.user/reference/ref-properties-build-path.htm#module-dependencies

Gradle

Official Gradle guide: https://guides.gradle.org/building-java-9-modules/

Official Gradle plugin: https://plugins.gradle.org/plugin/org.gradle.java.experimental-jigsaw

Open issue for "jigsaw support": https://github.com/gradle/gradle/issues/890

Third-party solutions

https://plugins.gradle.org/search?term=jigsaw

https://plugins.gradle.org/search?term=jpms

https://github.com/java9-modularity/gradle-modules-plugin (111 stars)

https://github.com/zyxist/chainsaw (70 stars)

https://github.com/xzel23/JpmsGradlePlugin (10 stars)

https://github.com/rgoldberg/gradle-java-modules (5 stars)

JavaFX

OpenJFX maintains a Gradle plugin for using JavaFX as modules: https://github.com/openjfx/javafx-gradle-plugin

JLink can distribute you application taking advantage of JPMS.

Gradle plugin: https://github.com/beryx/badass-jlink-plugin/ (107 stars)

module-info.java

The src/<source set>/java/module-info.java files define modules. The file has a special language specific module-info.java files.

module-info.java file looks like this:

module your.module {
   requires com.socket;
   exports us.other.module;
   uses some.module.Provider;
   provides com.socket.spi.NetworkSocketProvider
            with org.fastsocket.FastNetworkSocketProvider;
}

The module path

The short story is that there is a new path called the module path. This path exists on top of the classpath we are used to. The canonical classpath is now called "the unamed module". That is, all code without module-info.java files operates as it did in Java 8. See this Stack Overflow answer for more details.