Java › Java Platform Module System (JPMS)
What is an automatic module, and how does placing a plain (non-modularized) JAR on the module path (rather than the classpath) differ from leaving it on the classpath as part of the unnamed module?
IntermediateAnswer
An automatic module is created automatically by the JVM when a plain JAR (lacking its own module-info.java) is placed on the MODULE path rather than the classpath -- the JVM derives the automatic module's name from the JAR's filename (or an Automatic-Module-Name manifest entry if present, providing a more stable, intentional name than filename-derivation would), and grants it broad, permissive access (it reads every other module, and exports/opens ALL of its own packages unconditionally) -- this differs from the unnamed-module/classpath approach specifically in that OTHER named modules can now explicitly 'requires' this automatic module by its derived name, participating more fully in the module graph, which the pure unnamed-module approach doesn't support (named modules generally cannot 'requires' the unnamed module directly).
# A plain, non-modularized library JAR placed on the MODULE path becomes an automatic module
java --module-path mymodules:legacy-lib.jar --module com.example.myapp
// Now other named modules CAN explicitly declare a dependency on it
module com.example.myapp {
requires legacy.lib; // name derived from the JAR's filename, or its Automatic-Module-Name manifest entry
}Real-world example A team migrating toward full JPMS modularization places a legacy, non-modularized dependency JAR on the module path (as an automatic module) rather than the classpath, letting their own newly-modularized code explicitly declare and document a 'requires legacy.lib' dependency, an intermediate step providing more structure than leaving it on the classpath while the legacy JAR itself hasn't yet been properly modularized.