Defining a basic module
suggest changeA module is defined in module-info.java, the module descriptor, at the root of the module's source tree:
|-- module-info.java
|-- com
|-- example
|-- foo
|-- Foo.java
|-- bar
|-- Bar.java
Here is a simple module descriptor:
module com.example {
requires java.sql;
exports com.example.foo;
}
The module name should be unique and it is recommended that you use the same Reverse-DNS naming notation as used by packages to help ensure this.
The module java.base, which contains the basic classes, is readable by every module without a requires clause.
requires names another module this module reads. It does not import packages. There is no module named java.httpclient. The example depends on java.sql, which has existed since the module system was added in Java 9. The HTTP client lives in java.net.http, added in Java 11.
exports chooses which packages are visible to other modules.
com.example.foo is visible to other modules. Subpackages are not exported with it; each needs its own exports declaration.
Conversely, com.example.bar which is not listed in exports clauses will not be visible to other modules.