Skip to main content
Redhat Developers  Logo
  • Products

    Featured

    • Red Hat Enterprise Linux
      Red Hat Enterprise Linux Icon
    • Red Hat OpenShift AI
      Red Hat OpenShift AI
    • Red Hat Enterprise Linux AI
      Linux icon inside of a brain
    • Image mode for Red Hat Enterprise Linux
      RHEL image mode
    • Red Hat OpenShift
      Openshift icon
    • Red Hat Ansible Automation Platform
      Ansible icon
    • Red Hat Developer Hub
      Developer Hub
    • View All Red Hat Products
    • Linux

      • Red Hat Enterprise Linux
      • Image mode for Red Hat Enterprise Linux
      • Red Hat Universal Base Images (UBI)
    • Java runtimes & frameworks

      • JBoss Enterprise Application Platform
      • Red Hat build of OpenJDK
    • Kubernetes

      • Red Hat OpenShift
      • Microsoft Azure Red Hat OpenShift
      • Red Hat OpenShift Virtualization
      • Red Hat OpenShift Lightspeed
    • Integration & App Connectivity

      • Red Hat Build of Apache Camel
      • Red Hat Service Interconnect
      • Red Hat Connectivity Link
    • AI/ML

      • Red Hat OpenShift AI
      • Red Hat Enterprise Linux AI
    • Automation

      • Red Hat Ansible Automation Platform
      • Red Hat Ansible Lightspeed
    • Developer tools

      • Red Hat Trusted Software Supply Chain
      • Podman Desktop
      • Red Hat OpenShift Dev Spaces
    • Developer Sandbox

      Developer Sandbox
      Try Red Hat products and technologies without setup or configuration fees for 30 days with this shared Openshift and Kubernetes cluster.
    • Try at no cost
  • Technologies

    Featured

    • AI/ML
      AI/ML Icon
    • Linux
      Linux Icon
    • Kubernetes
      Cloud icon
    • Automation
      Automation Icon showing arrows moving in a circle around a gear
    • View All Technologies
    • Programming Languages & Frameworks

      • Java
      • Python
      • JavaScript
    • System Design & Architecture

      • Red Hat architecture and design patterns
      • Microservices
      • Event-Driven Architecture
      • Databases
    • Developer Productivity

      • Developer productivity
      • Developer Tools
      • GitOps
    • Secure Development & Architectures

      • Security
      • Secure coding
    • Platform Engineering

      • DevOps
      • DevSecOps
      • Ansible automation for applications and services
    • Automated Data Processing

      • AI/ML
      • Data Science
      • Apache Kafka on Kubernetes
      • View All Technologies
    • Start exploring in the Developer Sandbox for free

      sandbox graphic
      Try Red Hat's products and technologies without setup or configuration.
    • Try at no cost
  • Learn

    Featured

    • Kubernetes & Cloud Native
      Openshift icon
    • Linux
      Rhel icon
    • Automation
      Ansible cloud icon
    • Java
      Java icon
    • AI/ML
      AI/ML Icon
    • View All Learning Resources

    E-Books

    • GitOps Cookbook
    • Podman in Action
    • Kubernetes Operators
    • The Path to GitOps
    • View All E-books

    Cheat Sheets

    • Linux Commands
    • Bash Commands
    • Git
    • systemd Commands
    • View All Cheat Sheets

    Documentation

    • API Catalog
    • Product Documentation
    • Legacy Documentation
    • Red Hat Learning

      Learning image
      Boost your technical skills to expert-level with the help of interactive lessons offered by various Red Hat Learning programs.
    • Explore Red Hat Learning
  • Developer Sandbox

    Developer Sandbox

    • Access Red Hat’s products and technologies without setup or configuration, and start developing quicker than ever before with our new, no-cost sandbox environments.
    • Explore Developer Sandbox

    Featured Developer Sandbox activities

    • Get started with your Developer Sandbox
    • OpenShift virtualization and application modernization using the Developer Sandbox
    • Explore all Developer Sandbox activities

    Ready to start developing apps?

    • Try at no cost
  • Blog
  • Events
  • Videos

Jlink integration with OpenShift tech preview release

Enabling slim Java application containers

April 17, 2025
Jonathan Dowland
Related topics:
ContainersDeveloper ToolsJavaQuarkus
Related products:
Red Hat build of OpenJDKRed Hat OpenShiftRHEL UBI

Share:

    We are pleased to announce the first technology preview release of the jlink integration with Red Hat OpenShift for the Red Hat Universal Base Image (UBI) and Red Hat build of OpenJDK containers. We first publicly previewed this technology in a presentation at FOSDEM 2024. We will provide a quick overview of it in this article. For a deeper dive, please refer to the FOSDEM slides and recording.

    Background

    We ship two flavors of Universal Base Image and Red Hat build of OpenJDK containers: builder and runtime. The builders support OpenShift source-to-image (S2I). Using S2I, customers can set up automated pipelines to rebuild and deploy their application when their source is updated, or other relevant triggers.

    S2I is conceptually simple, and that simplicity has advantages. But one drawback is the resulting application container is layered on top of the builder image. For Java applications, that means they include the full Java Development Kit, including compiler, and Apache Maven tooling. Customers may wish for smaller containers, or a reduced attack-surface.

    In our 2021 article, we described how to configure OpenShift to perform a two-stage build, cherry-picking the application and layering it on top of the OpenJDK runtime images. The images produced by this method are smaller than plain S2I, but we felt we could make them even smaller. The OpenJDK runtime is about half the total image size, so it was our focus to find savings.

    Java modules and jlink

    In 2017, Project Jigsaw reorganized upstream OpenJDK into discrete modules. OpenJDK releases from version 9 onwards are modularized and include tooling for managing the following OpenJDK modules: 

    • jdeps are used to analyze an application to determine which modules it requires. 
    • jlink are used to produce a new OpenJDK runtime, containing only a specified sub-set of the full set of OpenJDK modules.

    Our runtime images are designed to be suitable for a wide range of users, and so included the majority of OpenJDK’s modules. What if we could remove OpenJDK modules that were not needed for a specific application?

    OpenShift and jlink

    By extending S2I, we can analyze the Java application to determine which OpenJDK modules it requires, and produce a minimized OpenJDK runtime, tailored to that application. Building upon the two-stage build, we extract both the application and the bespoke runtime and layer them on top of a runtime image. Figure 1 shows the OpenShift jlink three-stage build pipeline.

    Jlink BuilldConfig flow diagram
    License under CC BY-SA 4.0.
    Figure 1. OpenShift jlink three-stage build pipeline.

    As an additional bonus of this method, we can layer on top of the UBI micro image. This is a fraction of the size of the regular UBI runtime images, weighing in the order of 20-30MiB, or less than 10% the size of the UBI and OpenJDK runtime images.

    Combined, these space savings mean we can build ultra-lean application containers. In our experiments, the container size of a Quarkus-based application is reduced by 57% compared to the lean-containers technique. Figure 2 shows a breakdown of the OpenShift jlinked image sizes.

    Jlink container size breakdown pie chart
    Figure 2. A pie chart of the OpenShift jlinked-image size breakdown.

    How to get the tech preview image

    Initially, we’re releasing this feature as a separate tech preview container image using the Red Hat build of OpenJDK 21. This is to give us an opportunity to gather feedback from the community about this feature. We’d love to know what you think of this feature. Let us know what results you get with your real-world containers. Your feedback will help shape the future of this feature!

    We’ve packaged the required OpenShift configuration into this OpenShift template. Use the template in conjunction with the tech preview image, which is available from the Red Hat Ecosystem Catalog. You can also pull it from the Red Hat Container Registry with this command: registry.access.redhat.com/openjdk-tech-preview/openjdk-21-jlink-rhel9:latest.

    You can find the full step-by-step instructions in this README. The example application in our template is a Quarkus quickstart, configured to use the "Uber JAR" package type. We welcome your feedback.

    Related Posts

    • Build lean Java containers with the new Red Hat Universal Base Images OpenJDK runtime images

    • How to use Java container awareness in OpenShift 4

    • Build smaller container images using S2I

    Recent Posts

    • How to use RHEL 10 as a WSL Podman machine

    • MINC: Fast, local Kubernetes with Podman Desktop & MicroShift

    • How to stay informed with Red Hat status notifications

    • Getting started with RHEL on WSL

    • llm-d: Kubernetes-native distributed inferencing

    What’s up next?

    Download free preview chapters from Applied AI for Enterprise Java Development (O’Reilly), a practical guide for Java developers who want to build AI applications.

    Get the e-book
    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    Products

    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform

    Build

    • Developer Sandbox
    • Developer Tools
    • Interactive Tutorials
    • API Catalog

    Quicklinks

    • Learning Resources
    • E-books
    • Cheat Sheets
    • Blog
    • Events
    • Newsletter

    Communicate

    • About us
    • Contact sales
    • Find a partner
    • Report a website issue
    • Site Status Dashboard
    • Report a security problem

    RED HAT DEVELOPER

    Build here. Go anywhere.

    We serve the builders. The problem solvers who create careers with code.

    Join us if you’re a developer, software engineer, web designer, front-end designer, UX designer, computer scientist, architect, tester, product manager, project manager or team lead.

    Sign me up

    Red Hat legal and privacy links

    • About Red Hat
    • Jobs
    • Events
    • Locations
    • Contact Red Hat
    • Red Hat Blog
    • Inclusion at Red Hat
    • Cool Stuff Store
    • Red Hat Summit

    Red Hat legal and privacy links

    • Privacy statement
    • Terms of use
    • All policies and guidelines
    • Digital accessibility

    Report a website issue