36.2 Module Declarations

As we mentioned, a module must provide a module descriptor—metadata that specifies the module’s dependencies, the packages the module makes available to other modules, and more. A module descriptor is the compiled version of a module declaration that’s defined in a file named module-info.java. Each module declaration begins with the keyword module, followed by a unique module name and a module body enclosed in braces, as in

module modulename {
}

The module declaration’s body can be empty or may contain various module directives, including requires, exports, provideswith, uses and opens (each of which we discuss). As you’ll see in Section 36.3.5, compiling the module declaration creates the module descriptor, which ...

Get Java How to Program, Early Objects, 11th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.