DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Last call! Secure your stack and shape the future! Help dev teams across the globe navigate their software supply chain security challenges.

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workloads.

Releasing software shouldn't be stressful or risky. Learn how to leverage progressive delivery techniques to ensure safer deployments.

Avoid machine learning mistakes and boost model performance! Discover key ML patterns, anti-patterns, data strategies, and more.

Related

  • Jakarta WebSocket Essentials: A Guide to Full-Duplex Communication in Java
  • Java Is Greener on Arm
  • Mastering Date/Time APIs: Challenges With Java's Calendar and JDK Date/Time APIs
  • Java 23: What Developers Need to Know

Trending

  • AI-Based Threat Detection in Cloud Security
  • Teradata Performance and Skew Prevention Tips
  • A Guide to Container Runtimes
  • Contextual AI Integration for Agile Product Teams
  1. DZone
  2. Coding
  3. Java
  4. How to Deal With Different JDK Versions and Vendors

How to Deal With Different JDK Versions and Vendors

All those JDK versions from all those JDK suppliers giving you headaches? Here's an open-source project to simplify things with Docker.

By 
Sven Ruppert user avatar
Sven Ruppert
DZone Core CORE ·
Jun. 26, 19 · Tutorial
Likes (5)
Comment
Save
Tweet
Share
9.5K Views

Join the DZone community and get the full member experience.

Join For Free

We're going to talk about an open source project that includes a generator to build all needed scripts to create JDK and JDK/Maven Docker images.

Why Basic Docker Images Again?

Different people or organizations maintain the available "original" Docker images. This situation leads to small differences, and this was leading to different behaviors while using these images at runtime. Instead of hunting bugs, I decided to create a clean and straightforward solution. All Docker images are using the open source solution called Jabba to install the JDK.

A set of Docker images that are built precisely, in the same way, will help you to test your app against a matrix of JDK versions without handling the tiny details that are stealing your time.

Why Do We Need so Many Docker Images?

With the new release cycle that will bring us a new JDK every few months, we must decide how to deal with it in a project or product.

The generated Docker images help you test your application against different JDK versions and vendors. All images are created and pushed to the Docker Hub.

If you need a custom image, you can either use the provided images as a base or create your custom ones.

How to Use the JDK Docker Image Generator

In the following examples, I assume that Maven organizes the project. With Gradle, it should be the same, but maybe with different paths.

If you only need a JDK:

docker run \
       --rm \
       --name run \
       -v "$(pwd)":/usr/src/mymaven \
       -w /usr/src/mymaven \
       svenruppert/adopt:1.12.0-1 \
       java -jar target/myapp.jar


If you need Maven and a JDK:

docker run \
       --rm \
       --name compile \
       -v "$(pwd)":/usr/src/mymaven \
       -w /usr/src/mymaven \
       svenruppert/maven-3.6.1-adopt:1.12.0-1 \
       mvn clean install -Dmaven.test.skip=true


How to Generate

If you want to generate custom Dockerfiles by yourself, it would help if you edited the class Generator. Inside this class, you will find the templates as well.

This implementation is not super duper clean, but it works. Feel free to help me out and send a PR on GitHub!

The generated files, including the scripts for creating and pushing the images, are available under the directory _data. It will look like the following directory: https://github.com/svenruppert/docker-image-generator/tree/master/_data

You don't need to build these images by yourself, because all images are available in the official Docker registry.

Have a look at https://cloud.docker.com/u/svenruppert/.

Supported Versions and Vendors

Vendors

  • OpenJDK
  • Oracle
  • Oracle - GraalVM
  • Amazon
  • IBM
  • Adopt-OpenJ9
  • Zulu
  • Liberica

JDK Versions (not from all vendors)

  • JDK 6
  • JDK 7
  • JDK 8
  • JDK 9
  • JDK 10
  • JDK 11
  • JDK 12
  • JDK 13

These images are updated every few days, depending on the pre-/release date of the projects.

Java Development Kit Java (programming language)

Opinions expressed by DZone contributors are their own.

Related

  • Jakarta WebSocket Essentials: A Guide to Full-Duplex Communication in Java
  • Java Is Greener on Arm
  • Mastering Date/Time APIs: Challenges With Java's Calendar and JDK Date/Time APIs
  • Java 23: What Developers Need to Know

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends: