Installing the Default OpenJDK (Java 11)
At the time of writing, the latest LTS version of Java is version 11.
Follow the steps below to install Java OpenJDK 11 on your Ubuntu system:
First, update the apt package index with:
sudo apt update
Once the package index is updated install the default Java OpenJDK package with:
sudo apt install default-jdk
Verify the installation, by running the following command which will print the Java version:
java -version
The output will look something like this:
openjdk version "11.0.2" 2019-01-15 OpenJDK Runtime Environment (build 11.0.2+9-Ubuntu-3ubuntu118.04.3) OpenJDK 64-Bit Server VM (build 11.0.2+9-Ubuntu-3ubuntu118.04.3, mixed mode, sharing)
That’s it! At this point, you should have successfully installed Java on your Ubuntu system.
Once the package index is updated install the default Java OpenJDK package with:
sudo apt install default-jdk
Verify the installation, by running the following command which will print the Java version:
java -version
The output will look something like this:
openjdk version "11.0.2" 2019-01-15 OpenJDK Runtime Environment (build 11.0.2+9-Ubuntu-3ubuntu118.04.3) OpenJDK 64-Bit Server VM (build 11.0.2+9-Ubuntu-3ubuntu118.04.3, mixed mode, sharing)
That’s it! At this point, you should have successfully installed Java on your Ubuntu system.