Install OpenJDK JRE / JDK in Ubuntu 20.04 LTS

OpenJDK and the one developed by Oracle Corporation are two most popular packages available to build/execute java programs. In this article, we would discuss how to install OpenJDK JRE / JDK in Ubuntu 20.04 LTS release. Before that, it is important to know which package i.e. JDK or JRE we need to install.

For those users, who would just want to run Java applications then Java Runtime Environment (JRE) would suffice. But, for ones who would like to build and execute Java applications then they must opt Java Development Kit (JDK). We would like to clarify one thing here, it is not necessary to install JRE separately when we opt for JDK. OpenJDK Development Kit would install JRE by default.

We would first discuss OpenJDK JRE installation steps, then OpenJDK Development Kit. Also, we would install version 11 of OpenJDK JRE / JDK.

Note: Following operations would require you to have superuser privileges. In case you don’t have one, then contact your System Administrator for assistance.

Install OpenJDK Java Runtime Environment (JRE)

Since the package is already available in standard Ubuntu repository. Therefore, we need to update the Ubuntu repository to make the latest version of package available. Hence, issue the following in terminal –

sudo apt update

Now, to install OpenJDK Java Runtime Environment

sudo apt install openjdk-11-jre

This will install the necessary dependencies.

Install OpenJDK Development Kit (JDK)

As already discussed above, the packages are already available in standard Ubuntu repository. Therefore, first update the Ubuntu repository. This ensures we get to install the latest version of the package –

sudo apt update

Then, to install OpenJDK Development Kit

sudo apt install openjdk-11-jdk

It will install any related dependencies.

Lastly, to verify the Java version installed. Issue the following in terminal –

java -version

It would return with the output –

openjdk version "11.0.7" 2020-04-14
OpenJDK Runtime Environment (build 11.0.7+10-post-Ubuntu-3ubuntu1)
OpenJDK 64-Bit Server VM (build 11.0.7+10-post-Ubuntu-3ubuntu1, mixed mode, sharing)

Also, we would like to mention here that we have installed version 11.0.7 of OpenJDK JRE / JDK. This is the current supported version in Ubuntu distribution. Although you may choose to install other versions 8, 13 and 14 as well.

In conclusion, we have discussed how to install OpenJDK JRE / JDK in Ubuntu 20.04 LTS release.

What if, we have got two different Java versions installed on the same machine. Then, how would we let our system know which Java version to choose. Follow the article here to know more.