O'Reilly logo

Java 9 Modularity by Sander Mak, Paul Bakker

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 13. Scaling Down with Custom Runtime Images

Now that you’ve seen all the tools and processes to work with modular applications, there’s one more exciting opportunity to explore. In “Linking Modules”, you got a taste of creating runtime images tailored to a specific application. Only the modules required to run the application become part of the image. A minimal runtime image can be automatically generated with jlink by using explicit dependency information available in modules.

Creating a custom runtime image is beneficial for several reasons:

Ease of use

jlink delivers a self-contained distribution of your application and the JVM, ready to be shipped.

Reduced footprint

Only the modules that your application uses are linked into the runtime image.

Performance

A custom runtime potentially runs faster by virtue of link-time optimizations that are otherwise too costly or impossible.

Security

With only the minimum required platform modules in a custom runtime image, the attack surface decreases.

Even though creating a custom runtime image is an optional step, having a smaller binary distribution that runs faster is a compelling motivation—especially when applications target resource-constrained devices, such as embedded systems; or, when they run in the cloud, where everything is metered. Putting a custom runtime image into a Docker container is a good way to create resource-efficient cloud deployments.

Tip

Other initiatives are improving Java’s support for containers. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required