Module (JPMS)

A module (introduced in Java 9 as the Java Platform Module System / JPMS) is a higher-level grouping that contains one or more packages and explicitly declares what it requires from other modules and what it exports to them. The JDK itself is split into ~70 modules since Java 9.

module-info.java

// At the root of a module's source tree:
module com.example.app {
    requires java.sql;
    requires com.example.common;

    exports com.example.app.api;       // public to everyone
    exports com.example.app.internal to com.example.admin;  // public only to one module

    opens com.example.app.model;        // allows reflective access (for Jackson, Hibernate)
}

Benefits

  • Strong encapsulation — packages not in exports cannot be used by other modules, even if public.
  • Reliable configuration — missing required modules fail at module resolution, not deep into runtime.
  • Small runtimes with jlink — strip unused JDK modules to build a ~50 MB runtime image.

Adoption

Modules are standard in the JDK itself, but application adoption is mixed. Many libraries and frameworks still ship as plain JARs on the classpath. Applications can run with modular JDK classes without modularising their own code — an "automatic module" mode lets non-module JARs participate in the module graph.

classpath still works

You can keep using the classic -cp classpath indefinitely. The module system coexists with classic classpath loading. Don't feel obligated to modularise existing applications unless you gain something specific (smaller runtime via jlink, stronger isolation).