This chapter covers:
- creating runtime images that contain just the platform modules an app needs
- creating application images, which also include application code
- generating native application launchers
- judging the security, performance, and stability of images
- generating images across operating systems
- reducing image size and improving JVM performance
One of the key motivations for discussing modularity in Java has always been what is now called the Internet of Things (IoT). This is true for OSGi, Java’s most widely used third-party module system, which set out in 1999 to improve the development of embedded Java applications, and also for Project Jigsaw, which developed the JPMS and aimed to make the platform more scalable by allowing the creation of very small runtimes with just the code an (embedded) application needs.
This is where jlink
comes in. It’s a Java command line tool (in your JDK’s bin
folder) that you can use to select a number of platform modules and link them into a runtime image. Such a runtime image acts exactly as a JRE but contains just the modules you picked and the dependencies they need to function (as indicated by requires
directives). During that linking phase, jlink
can be used to further optimize image size and improve VM performance, particularly startup time.