Get Started with Oracle JDK 21: Installation Guide for Ubuntu/Debian

Jack Nothan
2 min readJan 22, 2024

--

Oracle JDK 21 is the latest version of the Java Development Kit, and it offers a range of new features and improvements for developers. If you are using Ubuntu or Debian as your operating system, you may be wondering how to install Oracle JDK 21 and get started with it. In this guide, we will walk you through the installation process step by step.

Step 1: Download Oracle JDK 21

The first step for Install Oracle JDK 21 on Ubuntu / Debian is to download the Oracle JDK 21 package from the official website. You will need to accept the license agreement before you can download the package. Once you have downloaded the package, you can proceed to the next step.

Step 2: Install Oracle JDK 21

To install Oracle JDK 21 on your Ubuntu or Debian system, you will need to use the terminal. Open a terminal window and navigate to the directory where you downloaded the JDK package. Then, use the following command to extract the package:

tar -xvzf jdk-21_linux-x64_bin.tar.gz

Next, move the extracted folder to a location where you want to install Oracle JDK 21. You can use the following command:

sudo mv jdk-21 /usr/lib/jvm/

After moving the folder, you will need to update your system’s alternatives to make sure that it recognizes Oracle JDK 21 as the default Java version. Use the following commands:

sudo update-alternatives — install /usr/bin/java java /usr/lib/jvm/jdk-21/bin/java 1

sudo update-alternatives — install /usr/bin/javac javac /usr/lib/jvm/jdk-21/bin/javac 1

sudo update-alternatives — config java

sudo update-alternatives — config javac

You can now verify that Oracle JDK 21 has been successfully installed by running the following commands:

java -version

javac -version

These commands should display information about Oracle JDK 21 and its version number.

Step 3: Set Environment Variables (Optional)

If you want to set environment variables for Oracle JDK 21, you can do so by editing your .bashrc file. Open the file in a text editor and add the following lines at the end:

export JAVA_HOME=/usr/lib/jvm/jdk-21

export PATH=$PATH:$JAVA_HOME/bin

Save and close the file, then run the following command in your terminal:

source ~/.bashrc

This will apply your changes and set up environment variables for Oracle JDK 21.

With these steps completed, you have successfully installed Oracle JDK 21 on your Ubuntu or Debian system and are ready to start using it for your development projects.

--

--

Jack Nothan

I am very interested in Linux and Windows and network operating system as well as network structure