Java examples for Object Oriented Design:Module
Creating a new directory somewhere on your file system named "myfolder"
Create a new file named module-info.java, which is the module descriptor.
In this file, list the module name as follows:
module org.firstModule {}
Create a folder named org within the myfolder directory.
Next, create a folder named firstModule within the org folder.
Now, create the bulk of the module by adding a new file named Main.java inside of the org.firstModule folder.
Place the following code within the Main.java file:
package org.firstModule; public class Main { public static void main(String[] args) { System.out.println("This is my first module"); } }
The easiest modules can be built with two files:
The module is packaged inside of a directory that is entitled the same as the module name.
In the example, this directory is named org.firstModule, as it follows the standard module naming convention.
In the example above, the module descriptor contains the module name, followed by {}.
In a more complex module, the names of other module dependencies can be placed within {}, along with the package names that this module exports for others to use.
The module descriptor should be located at the root of the module directory.
Inclusion of this file indicates to the JVM that this is a module.