13. Java Modules and the JPMS (Java Platform Module System)
Java Modules and the Java Platform Module System (JPMS) enhance modularity, encapsulation, and maintainability in Java applications. Introduced in Java 9, JPMS allows developers to organize code into well-defined modules with controlled dependencies, which helps mitigate issues like JAR conflicts and improves application performance and security. The chapter covers the structure of modules, the module-info.java descriptor, and various directives such as requires and exports, along with the benefits and limitations of the new system.
Enroll to start learning
You've not yet enrolled in this course. Please enroll for free to listen to audio lessons, classroom podcasts and take practice test.
Sections
Navigate through the learning materials and practice exercises.
What we have learnt
- Modules in Java are self-contained units that group packages and resources.
- JPMS introduces strong encapsulation and reliable configuration to avoid common dependency issues.
- Creating modules involves defining module-info.java files that specify dependencies and which packages to export.
Key Concepts
- -- Module
- A self-contained unit of code that groups related packages and specifies which packages to export and which modules to require.
- -- moduleinfo.java
- A file that acts as a descriptor for Java modules, declaring module dependencies and exports.
- -- JPMS
- Java Platform Module System, introduced in Java 9 to enhance modularity, security, and maintainability of Java applications.
- -- requires Directive
- A declaration in module-info.java that specifies dependencies between modules.
- -- exports Directive
- A declaration that specifies which packages are made accessible to other modules.
- -- opens Directive
- A declaration to open a package for reflection, allowing access to its members at runtime.
Additional Learning Materials
Supplementary resources to enhance your learning experience.