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

Comparing jlink Images to Traditional Deployments

Size comparisons, startup time benefits, and tradeoffs between jlink images and full JDK distributions.

Comparing jlink Images to Traditional Deployments

What you'll learn: How custom runtime images created with jlink stack up against traditional full JDK distributions in terms of size, performance, and trade-offs.


When you distribute a Java application, you traditionally bundle it with a full JRE or JDK, which weighs hundreds of megabytes. With jlink, you create a custom runtime image containing only the modules your application actually uses—like packing for a trip with just the essentials instead of your entire wardrobe.

Size Comparisons

A full JDK distribution typically ranges from 150-300+ MB depending on the platform. A jlink image for a modest modular application might be 30-50 MB, and minimal "Hello World" images can shrink below 30 MB with compression. This dramatic reduction matters for:

  • Container deployments (smaller Docker images)
  • Download times for client applications
  • Storage costs in cloud environments

Startup Time Benefits

Custom runtime images offer faster startup because:

  • The JVM loads fewer platform modules
  • Class Data Sharing (CDS) can be pre-configured
  • Reduced classpath scanning overhead

Real-world improvements range from 10-30% faster cold starts, significant for serverless functions and microservices.

Trade-offs

Flexibility vs Optimization: A full JDK runs any Java application; a jlink image runs only the modules you included. Adding functionality later requires rebuilding the image.

Maintenance burden: You manage separate runtime images per application, rather than a single shared JDK installation.

Debugging complexity: If you exclude jdk.compiler or debugging tools from your image, troubleshooting production issues becomes harder.

Platform specificity: jlink images are platform-dependent; distributing to Windows, Linux, and macOS requires three separate builds.

Key Takeaway:
jlink images drastically reduce size and improve startup times compared to full JDK distributions, but trade universal flexibility for application-specific optimization—choose them when deployment efficiency outweighs runtime flexibility needs.