How to Install OpenJDK 11 on Ubuntu 22.04 or 20.04

OpenJDK 11, the open-source version of the Java SE 11 Platform, offers a robust foundation for Java development. As you consider learning to install OpenJDK 11 on Ubuntu 22.04 Jammy Jellyfish or its older stable release of Ubuntu 20.04 Focal Fossa, it’s essential to recognize its pivotal role in the Java ecosystem. This long-term support (LTS) release, launched on September 25, 2018, provides extended security and bug fixes, ensuring a reliable platform for developers.

OpenJDK 11: Noteworthy Features:

  • Flight Recorder: A sophisticated event recording tool for diagnosing, profiling, and auditing Java applications.
  • HTTP Client API: Incorporated into the module by Java SE 11, this offers a standardized HTTP client API.
  • Epsilon GC: A no-op garbage collector tailored for managing small heaps or testing without GC disruptions.
  • ZGC: A scalable, low-latency garbage collector, ZGC can manage heaps ranging from hundreds of megabytes to multiple terabytes.
  • Enhanced Security: OpenJDK 11 bolsters several cryptographic algorithms, including ChaCha20-Poly1305 and TLS 1.3 support.

Why Choose OpenJDK 11?:

  • Application Compatibility: OpenJDK 11 is often the foundational or minimum version required for specific applications.
  • Longevity: As an LTS release, OpenJDK 11 enjoys prolonged security and bug fixes, ensuring a stable and secure environment.
  • Optimized Performance: This release improves performance, including quicker startup times and a minimized memory footprint.

Armed with this knowledge, the following sections will detail the installation process for OpenJDK 11 on Ubuntu 22.04 Jammy Jellyfish or Ubuntu 20.04 Focal Fossa, guiding you through the command line terminal steps.

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 on Ubuntu 22.04 or 20.04 via APT

Two options are available to install OpenJDK 11 on Ubuntu, with the most recommended one being 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 on Ubuntu 22.04 or 20.04

Switch Alternative Java Versions with Ubuntu 22.04 or 20.04

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.


In conclusion, using the default Ubuntu repository, you can easily install OpenJDK 11 on Ubuntu. OpenJDK 11 offers long-term support, making it a stable and secure option for developers seeking a reliable Java platform.

Share to...