OpenJDK 11 is a widely used, open-source implementation of the Java Platform, Standard Edition. It is known for introducing significant features like the new HTTP client, local-variable syntax for lambda parameters, and the flight recorder for monitoring. It offers a robust and flexible environment for developing and running Java applications, providing essential libraries and tools needed for Java development. As a Long-Term Support (LTS) release, OpenJDK 11 ensures stability and ongoing updates, making it a cornerstone in the Java ecosystem. Its extensive use by major organizations and open-source projects highlights its reliability and the active community support surrounding it.
The following guide will demonstrate the steps to install OpenJDK 11 on Ubuntu using the command-line terminal. We will be utilizing Ubuntu’s default APT repository, which contains the latest version of OpenJDK 11 for all supported Ubuntu versions, ensuring a straightforward and up-to-date installation process.
Update Ubuntu Before OpenJDK 11 Installation
We recommend updating the Ubuntu system to the latest version to ensure a smooth installation process without conflicts. Achieve this by running the following command in the terminal:
sudo apt update
sudo apt upgrade
The command updates the package lists and upgrades existing packages to their latest versions. Note that this step might take a while, depending on how many packages need updates. So, wait for the process to finish before moving to the next step.
Install OpenJDK 11
There are two options for installing OpenJDK 11 on Ubuntu; the most recommended one is through the default Ubuntu repository. To check the available OpenJDK 11 packages, enter the following command in the terminal:
apt-cache search openjdk-11
The output will display all the available packages related to OpenJDK 11, including the Java Development Kit (JDK) and Java Runtime Environment (JRE).
To install OpenJDK 11 JRE (Java Runtime Environment), execute the following command:
sudo apt install openjdk-11-jre
Alternatively, if you need to develop Java applications, you can install the OpenJDK 11 JDK (Java Development Kit) by running the following command:
sudo apt install openjdk-11-jdk
Additional OpenJDK 11 packages may be available in the repository, such as the OpenJDK 11 source code or the OpenJFX package for building JavaFX applications. You can install them using the same approach by searching for the package name using apt-cache search
and then installing it using sudo apt install
.
Additional Tips with OpenJDK 11
Switch Alternative Java Versions
Once you have installed OpenJDK 11 on your Ubuntu system, you may want to switch to it as your default Java version. You can use the update-alternatives
command, which manages the symbolic links used for different Java versions.
To list all the available Java alternatives, including the newly installed OpenJDK 11, run the following command in the terminal:
sudo update-alternatives --config java
The command displays a list of Java versions, their paths, and priorities. It will prompt you to choose the default Java version. Type the number that corresponds to OpenJDK 11 and press the Enter key.
After selecting the OpenJDK 11 version as the default, you can verify the change by running the following command:
java --version
This command will display the default Java version, which should now be OpenJDK 11. If you need to switch back to any other installed Java version, you can use the same process and select the appropriate number from the list.
Conclusion
In conclusion, installing OpenJDK 11 on Ubuntu 24.04, 22.04, or 20.04 LTS using the default Ubuntu repository is straightforward and efficient. As an LTS release, OpenJDK 11 provides a stable and secure Java platform with ongoing updates, making it a dependable choice for developers.