In this article, we would discuss how to install OpenJDK JRE / JDK in Ubuntu 22.04 release. We basically have two options available to us – JRE & JDK. JRE – Java Runtime Environment & JDK – Java Development Kit. If you are just trying to run a Java application then, installing JRE is more than enough. But, if you intend to build and execute a Java application then opt for JDK.
Also, before moving on to the installation part we would like to add that if you intend to install JDK (Java Development Kit) then, there is no need to install JRE separately. apt will automatically install that for you.
Furthermore, there are multiple versions of OpenJDK available through standard Ubuntu repository. We would help you install the currently supported version v11. You may opt to install v8, v17, v18.
Note: Following operations would require you to have superuser privileges. In case you don’t have one then, we advise you to contact your System Administrator.
We would first discuss the installation of OpenJDK JRE and then OpenJDK JDK.
Install OpenJDK JRE in Ubuntu 22.04
OpenJDK JRE package is already available through standard Ubuntu repository. Therefore, first update the repository to make the latest version of package available. Hence, open a terminal and issue the following –
sudo apt update
To install OpenJDK JRE –
sudo apt install openjdk-11-jre
It will install all the necessary dependencies too.
Install OpenJDK Java Development Kit in Ubuntu 22.04
As already discussed the packages are available through standard Ubuntu repository. Therefore, open a terminal and issue the following –
sudo apt update
Next, to install OpenJDK Java Development Kit –
sudo apt install openjdk-11-jdk
Lastly, to verify the Java version installed –
It would return with –
openjdk version "11.0.14" 2022-01-18 OpenJDK Runtime Environment (build 11.0.14+9-Ubuntu-0ubuntu2) OpenJDK 64-Bit Server VM (build 11.0.14+9-Ubuntu-0ubuntu2, mixed mode, sharing)
In conclusion, we have discussed how to install OpenJDK JRE / JDK in Ubuntu 22.04 release.
Additional Info –
If we have got two versions of OpenJDK installed. Then, we may want to choose a particular version for our work as default. Follow this article here to know how its done.