Install Java Temurin JDKs instead of OpenJDK on Ubuntu and Debian

As you may know, OpenJDK no longer provides official pre-built binaries or Docker images. Users who rely on readily available builds must migrate to other distributions to ensure they continue receiving feature updates and security patches. Eclipse Temurin, maintained by Adoptium, offers a reliable alternative with pre-built Java binaries and Docker images, making it an excellent choice for those transitioning from OpenJDK. In this guide, I explain how to install Temurin on distributions like Debian and Ubuntu.

Before we dive in, let me briefly explain why many developers are making the switch to Temurin. If you’d rather skip ahead to the installation steps, feel free to click here

Why Temurin?

Adoptium is an open-source project managed by the Eclipse Foundation, dedicated to providing high-quality, open, and free distributions of Java runtimes. It is part of the larger Java ecosystem and is widely supported by prominent industry players such as IBM, Red Hat, Microsoft, and others.

The flagship distribution of Adoptium is Eclipse Temurin, a high-quality, open-source Java Development Kit (JDK).

Eclipse Temurin is built from OpenJDK source code but undergoes additional rigorous testing and quality assurance processes15. It is certified by both the Java SE Technology Compatibility Kit (TCK) and the AQAvit quality verification suite, ensuring a high level of reliability and compatibility.

Free and Open Source

Unlike Oracle's JDK, which has commercial licensing restrictions, Eclipse Temurin is completely free and open source. This makes it an attractive option for developers and organizations looking to avoid potential licensing issues or costs.

Long-Term Support

Adoptium provides long-term support for Java versions, which can reduce the risk of compatibility issues and help organizations plan for the future. This is particularly valuable for enterprise environments that require stability and predictability.

Multi-Platform Support

Eclipse Temurin offers builds for a wide range of platforms and architectures, including Linux, Windows, macOS, and various CPU architectures like x64, ARM, and RISC-V13. This broad support makes it easier for developers to maintain consistency across different environments.

Community-Driven Development

Adoptium is backed by a diverse group of contributors and organizations, including major tech companies like Microsoft, IBM, and Red Hat1. This collaborative approach ensures that the project remains vendor-neutral and focused on the needs of the broader Java community.

Security Focus

Adoptium places a strong emphasis on security, with regular updates and patches to address vulnerabilities9. The project also pioneers software supply chain security practices, which is increasingly important in today's development landscape.

Installing Temurin

Now, that we clarified what Temurin offers let's install it.

Step 1: Install Pre-requisite Packages

Before adding the Temurin repository, ensure the required packages are installed:

sudo apt update
sudo apt install -y wget apt-transport-https

Step 2: Add the Temurin Repository

Add the Temurin repository to your system:

echo "deb [signed-by=/etc/apt/keyrings/adoptium.asc] https://packages.adoptium.net/artifactory/deb $(awk -F= '/^VERSION_CODENAME/{print $2}' /etc/os-release) main" | sudo tee /etc/apt/sources.list.d/adoptium.list

Download the Eclipse Adoptium GPG key and configure its apt repository:

sudo mkdir -p /etc/apt/keyrings
wget -O - https://packages.adoptium.net/artifactory/api/gpg/key/public | sudo tee /etc/apt/keyrings/adoptium.asc

Step 3: Install the Temurin package

Install the desired version of Temurin. For the latest LTS version (currently version 21), run:

sudo apt update
sudo apt install -y temurin-21-jdk

Step 4: Verify the Installation

To confirm that the installation was successful, check the Java version:

java -version

You should see output similar to this:

openjdk version "21.0.5" 2024-10-15 LTS
OpenJDK Runtime Environment Temurin-21.0.5+11 (build 21.0.5+11-LTS)
OpenJDK 64-Bit Server VM Temurin-21.0.5+11 (build 21.0.5+11-LTS, mixed mode, sharing)

Using Temurin as a Docker Image:

To use Eclipse Temurin as a Docker image, you can pull the latest version directly from the Adoptium Docker Hub repository. For example, to use Java 17, run:

# JDK version
docker pull eclipse-temurin:21-jdk

#JRE version
docker pull eclipse-temurin:21-jre

You can replace 21 with your desired Java version. Once downloaded, you can use this image in your Dockerfiles or directly in your containerized applications to build and run Java-based projects. Eclipse Temurin Docker images are well-maintained and regularly updated, ensuring compatibility and security.

Conclusion

Congratulations! Temurin is now installed and ready to use on your Ubuntu 24 system. Switching to Temurin ensures your Java applications remain secure and up-to-date. The steps above are quick and reliable for any Ubuntu 24 environment.

Have a great day!