Java Modules

Java 9 introduced the concept of modules to the JVM.

A module is a named, self-contained bundle of Java code. Modules may depend upon other modules, and may export packages from themselves to other modules that depend upon them. Module configuration is controlled by the module-info.java file.

In addition to the steps performed in the other tutorials (Eclipse, IntelliJ, Maven, Netbeans), the following steps are required to create a module:

  1. Add a module-info.java file under tutorialsrcmainjava.

  2. Name our module org.geotools.tutorial.quickstart:

    module org.geotools.tutorial.quickstart { }
    
  3. Then, add the modules we depend upon:

    module org.geotools.tutorial.quickstart {
        requires java.desktop;
        requires org.geotools.main;
        requires org.geotools.shapefile;
        requires org.geotools.swing;
        requires org.geotools.render;
    }
    

    You’ll notice the four GeoTools modules match those added as dependencies in the pom.xml. We also include the java.desktop module, which contains user interface components required for the app to function.

For a more detailed overview of the module system, refer to the State of the Module System.