14 Customizing runtime images with jlink

 

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.

14.1  Creating custom runtime images

14.1.1  Getting started with jlink

14.1.2  Image content and structure

14.1.3  Including services in runtime images

14.1.4  Right-sizing images with jlink and jdeps

14.2  Creating self-contained application images

14.2.1  Including application modules in images

14.2.2  Generating a native launcher for your application

14.2.3  Security, performance, and stability

14.3  Generating images across operating systems

14.4  Using jlink plugins to optimize images

sitemap