Java: Modules

Modules are defined in “module-info.java” in the source base directory.

module my.package.module1{      // the module name – not directly related to the package
	exports my.package;     // the package : as at the top of the java source files
	requires other.module;  // the other module name
}

This creates a module “my.package.module1” that exposes the code in Java package “my.package” and requires access to the contents of module “other.module”.

Can restrict access to packages

module my.package.module2{
	exports my.package to my.package.module1;  // parm1 = package, parm2 = module
}

Can state that anything calling this module also needs another module-info

module my.package.module2{
	...
	requires transitive other.module;
}