Today we are going to go through the steps on installing Java OpenJDK in Ubuntu operating system.
Open Terminal in Ubuntu
Execute the following commands:
sudo apt update && sudo apt upgrade -y
To confirm whether Java is already installed or not, execute the following command that displays the Java version:
java -version
If Java is not installed already it will display an output similar to the below:
Now that we have confirmed that Java is not installed, execute the following commands to install Java:
sudo apt install default-jre
The above command will install the JRE (Java Runtime Environment). In addition to the JRE, we will also be requiring the JDK (Java Development Kit). Execute the following command to install the JDK:
sudo apt install default-jdk
Now execute the command to check the Java version:
java -version
It will produce an output similar to the following: