Java Magazine, Mar/Apr 2018
ORACLE COM JAVAMAGAZINE MARCH APRIL 2018 47 microservices and containers As part of defining application modules and specifying which Java class libraries to import you can modularize the JVM itself The result is a custom Java runtime that strips out everything except what your application requires reducing the overall JVM and application footprint As with OSGi modularity from a size perspective might not be much of an issue for enterprise applications but its a big issue in the world of embedded and IoT development both very important business topics today Similar to OSGi the Java module system requires you to specify the modules your application is dependent upon via the new requires keyword and those your application or module exports for others to use Figure 3 How it difers is in its implementation With the Java module system you define a module info java file that outlines all the dependencies and the Java compiler enforces the modularity and validates that all of the dependent modules are present at compile time Listing 2 shows the module info java files where modularity requirements are defined for the sample application which consists of a user interface and math library implementation matching whats shown in Figure 3 Listing 2 Two sample module source files one for the math package and a second for the applications UI simulation math module info java module simulation math exports example simulation math Figure 3 Example showing Java modules available in the sample simulation application
You must have JavaScript enabled to view digital editions.