Course contentsShow
← Java
Lesson 2544 of 2,87047. Java Platform Module System (JPMS)Free lesson

What is jlink and Why Custom Runtime Images Matter

Understanding jlink's purpose: creating minimal, self-contained Java runtimes with only required modules.

What is jlink and Why Custom Runtime Images Matter

You'll learn what jlink is and why building custom runtime images can dramatically reduce the size and deployment footprint of your Java applications.

The Problem with Full JRE Distributions

Traditionally, running a Java application required shipping or assuming the presence of a full JRE (Java Runtime Environment) on the target machine. The JRE includes all platform modules—hundreds of megabytes of code—even if your application only uses a fraction of them. This wastes disk space, memory, and complicates deployment.

What is jlink?

jlink is a JDK tool introduced with JPMS that creates custom runtime images. A runtime image is a self-contained directory containing:

  • Only the modules your application explicitly depends on (via requires)
  • The necessary platform modules (like java.base)
  • A complete Java runtime launcher
  • No extraneous JDK modules you don't need

Think of it as shrink-wrapping your application with a minimal Java runtime—like packing only the tools you'll actually use for a camping trip instead of bringing your entire garage.

Why Custom Runtime Images Matter

Size reduction: A full JRE can exceed 200 MB. A custom image might be 30-50 MB or even smaller, containing only java.base, java.logging, and your application modules.

Faster startup: Less code to load means quicker initialization.

Simplified deployment: You distribute one self-contained package—no "Java version mismatch" issues.

Security: Fewer modules mean a smaller attack surface; unused code can't be exploited.

When to Use jlink

jlink works only with fully modular applications—your code and all dependencies must be on the module path with proper module-info.java descriptors. This is why the migration strategies and modular JARs you've learned are essential prerequisites.

Key Takeaway: jlink creates minimal, self-contained Java runtime images by bundling only the modules your application requires, reducing size, improving security, and simplifying deployment.