☰ See All Chapters |
Module descriptor - module-info.java
Java packages are used to group similar data types (class, interface, enum etc..) as well as packages are used to group resources such as property file, XML files, etc… Now how should we group these packages? Yes this is possible by using module descriptor. Module descriptor is a java file whose name should be module-info. This module-info.java file should be placed inside the root of packages. Example it should be placed inside src folder.
It can also be placed inside any resource folder. Make sure the folder is available in classpath.
module-info.java file should declare the module facets. Below is the syntax of module descriptor:
module modulename {
}
Example:
module com.java4coding {
}
Naming convention is same as for packages. The module declaration’s body can be empty or may contain below module directives:
Follow our next chapter to learn about these directives.
All Chapters