Welcome to our tutorial on installing Temurin OpenJDK 21 on Debian 12 | Debian 11. Java is an object-oriented programming language with a different levels of abstraction and as few operational requirements as feasible. It is a general-purpose programming language that allows programmers to write once and execute anywhere, which means that compiled Java code may run on any platform that supports Java without the need to recompile.
Eclipse Adoptium
For broad usage across the Java environment, Eclipse Adoptium delivers runtime binaries that are top of the line, enterprise-caliber, cross-platform, accessible permitted, Java SE TCK-tested, and compliance. The Eclipse Adoptium Top-Level Project’s objective is to create high-quality processing performance and technological tools for usage in the Java environment.
Why Eclipse Adoptium Projects?
Eclipse Adoptium projects have the following uniqueness:
- TCK Testing Infrastructure: Large – scale project for the execution of Java SE TCKs in order to assure conformance and interoperability.
- Runtimes and Development Kits: Accessible on a wide range of processor core and system software configurations, and enabling the range of APIs defined by various editions of Java SE.
- System local installers, container images, download servers, a webpage, and artifact repositories are examples of techniques for getting and controlling the installation of runtime technologies.
- JDK Mission Control is a set of low-cost monitoring and debugging tools for the Java Virtual Machine.
Install Temurin OpenJDK 21 LTS on Debian 12 / Debian 11
The steps below will guide on how to Install Temurin OpenJDK 21 on Debian 12 / Debian 11.
Step 1: System update
Make sure your Debian 12|11 server is up to date.
sudo apt update -y
Step 2: Install Temurin OpenJDK 21 on Debian 12|11
Visit Temurin OpenJDK 21 page to download the latest archive.
sudo apt install -y wget
sudo wget https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.6%2B7/OpenJDK21U-jdk_x64_linux_hotspot_21.0.6_7.tar.gz
Extract the downloaded Temurin OpenJDK 21 archive file using tar command.
tar xzf OpenJDK21U-jdk_x64_linux_hotspot_21.0.6_7.tar.gz
Step 3: Configure Java Environment
Move the resulting folder after extraction to /opt
directory.
sudo mv jdk-21.0.6+7 /opt/
Now, configure Java environment:
$ sudo vim /etc/profile
export JAVA_HOME=/opt/jdk-21.0.6+7
export PATH=$JAVA_HOME/bin:$PATH
Source your profile file and examine java command:
source /etc/profile
Check Java version.
$ echo $JAVA_HOME
/opt/jdk-21.0.6+7
$ java -version
openjdk 21.0.6 2025-01-21 LTS
OpenJDK Runtime Environment Temurin-21.0.6+7 (build 21.0.6+7-LTS)
OpenJDK 64-Bit Server VM Temurin-21.0.6+7 (build 21.0.6+7-LTS, mixed mode, sharing)
Step 4: Setting Java default version
To set java default version, first add AdoptJDK 21 to /usr/bin/java
path:
sudo update-alternatives --install /usr/bin/java java /opt/jdk-21.0.6+7/bin/java 1
Then select Java version to use as default by running the following command:
$ sudo update-alternatives --config java
There are 2 choices for the alternative java (providing /usr/bin/java).
Selection Path Priority Status
------------------------------------------------------------
0 /usr/lib/jvm/java-17-openjdk-amd64/bin/java 1111 auto mode
* 1 /opt/jdk-21.0.6+7/bin/java 1 manual mode
2 /usr/lib/jvm/java-20-openjdk-amd64/bin/java 1111 manual mode
Press <enter> to keep the current choice[*], or type selection number: 1
Using Temurin OpenJDK 21 on Debian 12|11
We’ll make a Hello World program to test Temurin OpenJDK 21.
$ cat > hello_world.java <<EOF
public class helloworld {
public static void main(String[] args) {
System.out.println("Hello World! Temurin is powerful");
}
}
EOF
Now, run the above code as shown below:
$ java hello_world.java
Hello World! Temurin is powerful
Conclusion
Finally, you’ve installed Temurin OpenJDK 21 on Debian 12|11 successfully. We hope you learned something new from this tutorial. Coding in Java is a lot of fun. Enjoy!
Related Guides: