Java requires Keyword
Example
Use requires in a module's module-info.java file:
module mymodule {
requires module1;
requires transitive module2;
requires static module3;
}
Definition and Usage
The requires keyword is a module directive that specifies a different module which this module depends on.
There are two modifiers which can be added to the requires directive: transitive and static
The transitive modifier allows other modules to use this module without also having to declare this same requirement.
The static modifier makes the requirement optional during runtime. It allows this module to run even if the other module is not present.
Note: The requires keyword is a module directive meant to be used in the module-info.java file of a module.
The requires keyword was new in Java 9.