Skip to main content
Version: 1.2

Linux

Checking Your Java Version

To check if Java is already installed and which version you have, run the following command:

java -version

If Java 21 or higher is installed, you'll see output similar to:

openjdk version "21.0.x" 20xx-xx-xx
OpenJDK Runtime Environment (build 21.0.x+x)
OpenJDK 64-Bit Server VM (build 21.0.x+x, mixed mode)

If you don't have Java installed or have a version lower than 21, follow the instructions below for your operating system.

info

If you already have a Java version newer than 21, there is no need to downgrade. The application works with any Java 21 or later release.

Ubuntu 22

Update package index.

sudo apt update

Install OpenJDK 21.

sudo apt install openjdk-21-jre-headless -y

Verify installation.

java -version

Ubuntu 24

Update package index.

sudo apt update

Install OpenJDK 21.

sudo apt install openjdk-21-jre-headless -y

Verify installation.

java -version

CentOS/RHEL 9

Install OpenJDK 21.

sudo dnf install -y java-21-openjdk-headless

Verify installation.

java -version

CentOS/RHEL 10

Install OpenJDK 21.

sudo dnf install -y java-21-openjdk-headless

Verify installation.

java -version

Debian 12

info

Java 21 is not available in the default Debian 12 repositories. Follow the Manual installation steps below to install OpenJDK 21 from Eclipse Temurin.

Debian 13

Update package index.

sudo apt update

Install OpenJDK 21.

sudo apt install openjdk-21-jre-headless -y

Verify installation.

java -version

Manual Installation

Use this method if your distribution does not provide OpenJDK 21 in its package repositories.

Download the OpenJDK 21 tarball from Eclipse Temurin. Select Linux, your architecture (x64 or aarch64), and the .tar.gz package type.

Extract the archive to /opt.

sudo tar -xzf OpenJDK21U-jdk_x64_linux_hotspot_*.tar.gz -C /opt

The extracted directory will be named something like jdk-21.0.x+x. Set JAVA_HOME and add Java to PATH by adding the following lines to /etc/environment.

JAVA_HOME="/opt/jdk-21.0.x+x"
PATH="/opt/jdk-21.0.x+x/bin:$PATH"

Replace jdk-21.0.x+x with the actual directory name from the extraction step.

Reload environment variables.

source /etc/environment

Optionally, register Java with update-alternatives so it is picked up as the system default.

sudo update-alternatives --install /usr/bin/java java $JAVA_HOME/bin/java 1000
sudo update-alternatives --config java

Verify installation.

java -version

Setting JAVA_HOME

After installing Java 21 on Linux, it's recommended to set the JAVA_HOME environment variable:

Find the Java installation path

sudo update-alternatives --config java

Add JAVA_HOME to /etc/environment (adjust the path based on your installation)

echo 'JAVA_HOME="/usr/lib/jvm/java-21-openjdk-amd64"' | sudo tee -a /etc/environment

Reload environment variables

source /etc/environment

Verify JAVA_HOME is set correctly

echo $JAVA_HOME
info

The exact path to your Java installation may vary depending on your distribution and installation method.