Java Magazine, May/June 2019
ORACLE COM JAVAMAGAZINE MAY JUNE 2019 26 containers Historically packages that were meant to be internal relied upon implicit naming such as ch frankel c internal However there was no technical way to enforce this constraint Java 9 tried to address this problem by providing another way to manage visibility modules There are several kinds of modules System modules These modules are provided by the JVM Application modules An application can be made into an application module by providing a module info class at its root Automatic modules By adding an Automatic Module Name entry in a JARs MANIFEST MF the specified module will be treated as an automatic module Unnamed module A JAR that is not a system module an application module or an automatic module is an unnamed module A Java 9 or later application that has been modularized makes use of a module info file located at the root This file is a manifest that contains the module name and declares which module dependencies are required At runtime the loader reads that manifest to load only the modules that are necessary With this design its possible to eliminate unnecessary modules that are part of the JDK which is the To reduce the overall size of an image you can take advantage of the module system and distribute only the required modules of the JDK mission of jlink As the oficial documentation states You can use the jlink tool to assemble and optimize a set of modules and their dependencies into a custom runtime image jlink enables you to use the underlying module configuration of an application to deliver a custom JRE along with the application Using the same mechanics it also allows you to create an executable out of the application so the deliverable is completely self suficient and doesnt rely on the target system having a compatible JRE Laying the Foundation Lets examine jlink starting with the simplest possible application Hello World Here it is in all its glory
You must have JavaScript enabled to view digital editions.