
- Java Tutorial
- Java - Home
- Java - Overview
- Java - Environment Setup
- Java - Basic Syntax
- Java - Object & Classes
- Java - Constructors
- Java - Basic Datatypes
- Java - Variable Types
- Java - Modifier Types
- Java - Basic Operators
- Java - Loop Control
- Java - Decision Making
- Java - Numbers
- Java - Characters
- Java - Strings
- Java - Arrays
- Java - Date & Time
- Java - Regular Expressions
- Java - Methods
- Java - Files and I/O
- Java - Exceptions
- Java - Inner classes
- Java Object Oriented
- Java - Inheritance
- Java - Overriding
- Java - Polymorphism
- Java - Abstraction
- Java - Encapsulation
- Java - Interfaces
- Java - Packages
- Java Advanced
- Java - Data Structures
- Java - Collections
- Java - Generics
- Java - Serialization
- Java - Networking
- Java - Sending Email
- Java - Multithreading
- Java - Applet Basics
- Java - Documentation
- Java Useful Resources
- Java - Questions and Answers
- Java - Quick Guide
- Java - Useful Resources
- Java - Discussion
- Java - Examples
Importance of Module Descriptor in a Module in Java 9?
A module is a collection of code in the form of classes organized in packages and static resources such as property files or others. It provides the outside environment with all the information that can be required to use that module. The module descriptor is a key source of the module system, and it's compiled version of a module declaration specified in a file named "module-info.java" file at the root of the module’s directory hierarchy.
The module describes itself by a module declaration as below
module com.myproject.module1 { requires com.myproject.module2; exports com.myproject.project1; exports com.myproject.project2; }
Below are some of the module descriptors described:
- module module. name: declares a module called module.name.
- requires module. name: specifies that our module depends on the module. name, allows this module to access public types exported in the target module.
- requires a transitive module. name: Any modules that depend on this module automatically depend on module.name.
- exports pkg.name: It says that our module exports public members in package pkg.name for every module requiring this one.
- exports pkg.name to module.name: It is the same as above, but limits which modules can use the public members from the package pkg.name.
- uses class. name: It makes the current module a consumer for service class.name.
- provides class.name with class.name.impl: It registers class.name.impl class a service that provides an implementation of the class.name service.
- opens pkg.name: It allows other modules to use reflection to access the private members of package pkg.name.
- opens pkg.name to module.name: It does the same, but limits which modules can have reflection access to the private members in the pkg.name.
- Related Articles
- How to create a module in Java 9?
- What is Module System in Java 9?
- What are the characteristics of a module in Java 9?
- What are the benefits of a module in Java 9?
- What is an unnamed module in Java 9?
- What are the different module types in Java 9?
- What are the different compilation modes of a module in Java 9?
- What are the components in a module-info file in Java 9?
- When to use the ServiceLoader class in a module in Java 9?
- How can we display all module names in Java 9?
- How can we modify an existing module in Java 9?
- What are the advantages and disadvantages of the Module System in Java 9?
- What is the use of the "requires" clause in a module-info file in Java 9?
- What is the use of the "export" clause in a module-info file in Java 9?
- Import a module in Python

Advertisements