Home >Java >javaTutorial >What are unnamed modules in Java 9?
An unnamedmodule is the unnamedpackage concept. It is a module in which a package or class cannot be defined in any named module, but is present in the classpath in a jar file. If our code attempts to load a type from these files, the module system attempts to find the Classpath and load it.
An unnamed module will read all other modules, including all named , built-in platform modules , and export all its packages. Packages in unnamed modules can be ignored, this is also defined in named modules.
Unnamed modules can access:
<strong>java --module-path out -module moduleName/com.tutorialspoint.UnnamedModuleTest</strong>
public class UnnamedModuleTest { public static void main(String args[]) { <strong>Module </strong>module = UnnamedModuleTest.class.<strong>getModule()</strong>; System.out.println("Module: "+ module); System.out.println("Name: " + module.<strong>getName()</strong>); System.out.println("isNamed: " + module.<strong>isNamed()</strong>); System.out.println("Descriptor: " + module.<strong>getDescriptor()</strong>); } }
<strong>Module: unnamed module @c818063 Name: null isNamed: false Descriptor: null</strong>
The above is the detailed content of What are unnamed modules in Java 9?. For more information, please follow other related articles on the PHP Chinese website!