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
Newsletter
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • I Built a Java Version Manager by Fixing Other Tools' Open Bugs
  • A Spring Boot App With Half the Startup Time
  • Alternative Structured Concurrency
  • Optimizing Java Applications for Arm64 in the Cloud

Trending

  • Spring AI on Local LLMs
  • Adding Graph Retrieval to a RAG Pipeline With Python
  • Why Kotlin or Java Is the Wrong Question For Enterprises
  • To Switch, or Not to Switch the AI Model

Draft This article hasn't been published, so readers can't see it.

In moderation This article is waiting for review, so readers can't see it yet.

Deleted This article has been deleted, so readers can't see it.

  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
DZone Core CORE ·
Jun. 26, 19 · Tutorial
Post on X (opens in a new tab) Share on LinkedIn (opens in a new tab)
10.0K Views

Join the DZone community Save articles, join the discussion, and download Refcards and Trend Reports with a free account.

Join for free Already a member? Log in

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

  • I Built a Java Version Manager by Fixing Other Tools' Open Bugs
  • A Spring Boot App With Half the Startup Time
  • Alternative Structured Concurrency
  • Optimizing Java Applications for Arm64 in the Cloud

Partner Resources

×

Comments

Loading comments

The comments didn't load

Please try again in a moment.

Likes

Loading

The next likes didn't load. Please try again.

The likes didn't load

Please try again in a moment.

See who liked this

Log in or join DZone for free to see who liked this article.

Log in Join for free
  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

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 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook