How to get the OpenJDK binary tar/zip file?

Since Oracle updated their license for Java 8, a lot of companies started officially maintaining OpenJDK, such as Redhat, Amazon, Alibaba and etc. It’s a good time to switch to OpenJDK.

Unlike Oracle, Redhat doesn’t provide the portable tar/zip of pre-built OpenJDK Linux edition. The zip files are only for Windows. Redhat recommends you to use the offical RPM package to install. Generally, it’s better solution but sometimes it’s very inconvenience, especially when you don’t have the permission but you want to have a quick deployment.

What to do? Docker could help!

  • Pull the image of the CentOS you need. In my case, I used a CentOS 7.7 image.

  • Start the container

  • Install the OpenJDK you need, such as OpenJDK8 or OpenJDK11. For example,

  • Find where the JDK is. In my case, it’s /usr/lib/jvm/java-11-openjdk-11.0.5.10-0.el7_7.x86_64

  • Make a tar file of that folder
  • Copy this tar file out to your local.

By this way, you can get the compatible tar/zip file out. Usually, the dependencies should be fulfilled.