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

Related

  • Alternative Structured Concurrency
  • Optimizing Java Applications for Arm64 in the Cloud
  • 1-Line IO in Java
  • Jakarta WebSocket Essentials: A Guide to Full-Duplex Communication in Java

Trending

  • Implementing Secure API Gateways for Microservices Architecture
  • 7 Technology Waves I’ve Seen in 30 Years of Software — Will AI Be the Next Real Transformation?
  • Implementing Observability in Distributed Systems Using OpenTelemetry
  • 5 Common Security Pitfalls in Serverless Architectures
  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.8K 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

  • Alternative Structured Concurrency
  • Optimizing Java Applications for Arm64 in the Cloud
  • 1-Line IO in Java
  • Jakarta WebSocket Essentials: A Guide to Full-Duplex Communication in Java

Partner Resources

×

Comments

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

  • 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