How to install OpenJDK 17 on Ubuntu 20.04 or 22.04

Java, with its robust cross-platform capabilities and a thriving ecosystem of applications, remains a fundamental technology for developers and organizations alike.

As the Java ecosystem evolves, staying up to date with the latest Java Development Kit (JDK) versions is crucial for taking advantage of new features, improvements, and security enhancements.

OpenJDK, the open-source implementation of the Java Platform, Standard Edition (Java SE), has become the preferred choice for many developers.

The latest OpenJDK LTS version is 21, but version 17 is still regularly maintained and it’s security support ends in 6 years, meaning that many things still rely on it and require it since end of life is not even near.

In this article, we will teach you how to install OpenJDK 17 on Ubuntu 20.04 or 22.04 version. So let’s get started.

Use cases and features of OpenJDK 17

Use Cases:

  1. Server-Side Applications: OpenJDK 17 is well-suited for building server-side applications, such as web servers, microservices, and enterprise-level systems. Its LTS status ensures stability for mission-critical applications.
  2. Mobile Development: Java continues to be a popular choice for Android app development, and OpenJDK 17 can be used for building Android apps, particularly with the adoption of Java 8 features in the Android ecosystem.
  3. Cloud-Native Development: OpenJDK 17 is suitable for developing cloud-native applications and microservices, benefiting from its performance enhancements and support for modern containerization technologies.


  1. Pattern Matching for instanceof: OpenJDK 17 introduced pattern matching for the instanceof operator. This simplifies code by allowing developers to combine type checking and casting in a single operation.
  2. Strong Encapsulation of Internal APIs: OpenJDK 17 continued the process of encapsulating internal APIs, making the Java platform more modular and secure. This can help prevent unintended dependencies on internal APIs.
  3. Foreign Function and Memory API (Incubator): This feature allows Java code to interoperate with native code more efficiently. It’s especially useful for tasks like working with machine learning libraries or low-level system interactions.
  4. Deprecation of Applet API: The Applet API, which was widely used for web applets in the past, has been deprecated in OpenJDK 17, marking its gradual phasing out in favor of modern web technologies.
  5. Sealed Classes: OpenJDK 17 added the ability to declare classes as “sealed,” which restricts which other classes or interfaces can extend or implement them. This enhances code maintainability and security.
  6. Deprecation of RMI Activation System: The Remote Method Invocation (RMI) Activation System has been deprecated in OpenJDK 17, reflecting the decreasing usage of this technology in modern Java applications.

OpenJDK 17 Installation process

Step 1: Update your Ubuntu

For this article, we are using one of our cheap, affordable and fast ServerLynx Linux KVM VPS machines. By using SL50OFF code you can get one too with 50% discount!

In your terminal, run the command from below.

sudo apt update && sudo apt upgrade -y

Depending on how recently you have run the updates, it may take a few minutes or a few seconds.

Step 2: Installing from Ubuntu repository

This command will show us the available packages.

apt-cache search openjdk | grep openjdk-17
step 1 check available openjdk 17 packages on ubuntu

It really depends what you need, but if you are not sure, feel free to go with both openjdk-17-jre and openjdk17-jdk.

The commands are:

sudo apt install openjdk-17-jre
sudo apt install openjdk-17-jdk

The process is relatively quick and it should be over right away.

Step 3: Confirm that OpenJDK is properly installed

java --version
step 2 confirm openjdk 17 installation on ubuntu

Nice! This means it all went good.

How to remove OpenJDK 17 from Ubuntu 20.04 or 22.04?

Don’t worry, its easy, just like the installation.

If for any reason you want to remove these packages and purge any traces of them, just run the following command and that should do it.

sudo apt remove openjdk-17-jre openjdk-17-jdk --purge

After that is done, you can confirm it with java –version command again. If nothing comes out, it means your job is done.


Installing OpenJDK 17 is relatively easy and straightforward process, and while there are some other ways of doing it, installation from the repository is recommended.

Make sure to update your system from time to time so your OpenJDK 17 would receive latest security updates. Don’t risk it!

Similar Posts