- Java 9:Building Robust Modular Applications
- Dr. Edward Lavieri Peter Verhas Jason Lee
- 142字
- 2025-04-04 17:08:34
Reliable configuration
As suggested earlier in this chapter, modules provide a reliable configuration of our Java 9 applications that solves the classpath problem in earlier versions of the Java platform.
Java reads and interprets modular declarations making the modules readable. These readable modules permit the Java platform to determine if any modules are missing, if there are duplicate libraries declared, or there are any other conflicts. In Java 9, very specific error messages will be generated and output by the compiler or at runtime. Here is an example of a compile-time error:
src/com.three19.irisScan/module-info.java: error: module not found: com.three19.irisScan
requires com.three19.irisCore;
^
1 error
Here is an example of a runtime error that would occur if the module com.three19.isrisCore was not found, but required by the com.three19.irisScan app:
Error occurred during initialization of VM
java.lang.module.ResolutionException: Module com.three19.irisCore not found, required by com.three19.irisScan app