How to install OpenJDK on Linux

Posted: | Last updated: | 1 minute read

This blog shows you how to install OpenJDK on Linux distributions, a free and open-source implementation of the Java Platform, Standard Edition (Java SE).

Note: Different Linux destribution has their own way of managing softwares and packages.

Prerequsities

  • You need to know, that which Linux distribution and version you are using. Some older version version of JDKs are deprecated, and no longer supported.

Install OpenJDK in CentOS

CentOS comes with yum package manager by default.

$ sudo yum -y update

Install OpenJDK 8

Installing OpenJDK 8 on CentOS 7.6.1810

Total download size: ~ 48 M
Installed size: ~ 163 M

$ sudo yum install java-1.8.0-openjdk

Verify version:

$ sudo java -version

Sample output:

openjdk version "1.8.0_212"
OpenJDK Runtime Environment (build 1.8.0_212-b04)
OpenJDK 64-Bit Server VM (build 25.212-b04, mixed mode)

Install OpenJDK in Ubuntu

Following are steps to install different JDK versions in Ubuntu OS.

Install OpenJDK 8

Installing OpenJDK 8 on Ubuntu 18.10

$ sudo apt-get update
sudo apt-get install openjdk-8-jdk

Verify version:

$ sudo java -version

Sample output:

openjdk version "1.8.0_212"
OpenJDK Runtime Environment (build 1.8.0_212-b04)
OpenJDK 64-Bit Server VM (build 25.212-b04, mixed mode)

Verify version:

$ sudo java -version

Sample output:

openjdk version "1.8.0_212"
OpenJDK Runtime Environment (build 1.8.0_212-8u212-b03-0ubuntu1.18.10.1-b03)
OpenJDK 64-Bit Server VM (build 25.212-b03, mixed mode)

Install OpenJDK in OpenSUSE

Following are steps to install different JDK versions in openSUSE Tumbleweed.

Install OpenJDK 8

Install OpenJDK in AmazonLinux

asdsdas d asdasd as das

Install OpenJDK 8

Set Java’s Home Environment

Let’s set JAVA_HOME and JAVA_PATH for your installation.

I will be using CentOS as example for setting up JAVA_HOME and JAVA_PATH

Find Java home path

$ update-alternatives --config java