Java 9 Modules: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 21: Line 21:


All the code from classpath lives together in the "unnamed" module.
All the code from classpath lives together in the "unnamed" module.
==<tt>module-info.java</tt>==
<code>module-info.java</code> is file that represents a module descriptor.
If code is compiled without a <code>module-info.java</code>, the code will be part of the "unnamed" module and can see all other code in the "unnamed", <code>java.base</code> and modules in the <code>java.se</code> root module. That means if no <code>module-info.java</code> is present in the project, everything should still work as in Java 8. Dependencies should be put on the [[#Classpath|classpath]], not on [[#Modulepath|modulepath]].


=Organizatorium=
=Organizatorium=
* Classpath and module path is mutually exclusive.
* Classpath and module path is mutually exclusive.

Revision as of 21:10, 18 May 2021

Internal

TODO

Concepts

Module

A module is a JAR with a module descriptor, available to the JVM on the module path.

Modulepath

All the code on the modulepath lives in their own "named" modules.

Package Relationship to Modules

A package can only be accessed from one module. Hierarchical packages are treated as separate, so "java.util" and "java.util.logging" can exist in different modules. Only public fields and methods are accessible in the code of exported packages of other modules.

Classpath

All the code from classpath lives together in the "unnamed" module.

module-info.java

module-info.java is file that represents a module descriptor.

If code is compiled without a module-info.java, the code will be part of the "unnamed" module and can see all other code in the "unnamed", java.base and modules in the java.se root module. That means if no module-info.java is present in the project, everything should still work as in Java 8. Dependencies should be put on the classpath, not on modulepath.

Organizatorium

  • Classpath and module path is mutually exclusive.