How To Install OpenJDK 17 on Debian 11

This tutorial intends to teach you to How To Install Java OpenJDK 17 on Debian 11.

OpenJDK is a powerful, free, and open-source implementation of Java. OpenJDK is another app that you can use instead of Oracle JDK because it is free and high-performance.

In this article, you will learn to download Java JDK 17 and configure your environment path on Debian 11, and test your Java 17 installation by creating a sample project.

Note: We have other guides that include the Java installation on different OS which are as follows:

Set up OpenJDK 17 on Ubuntu 20.04

How To Install OpenJDK 17 on AlmaLinux 9

How To Install OpenJDK 17 on Centos 7

How To Install OpenJDK 17 on Debian 11?

To complete this guide, you must have access to your server as a non-root user with sudo privileges. For this purpose, you can follow this guide on Initial Server Setup with Debian 11. Now follow the steps below to start your Java 17 installation:

Step 1 – Download OpenJDK 17 Binary Package

First, you must run the system update with the following command:

sudo apt update

Then, you need to visit the JDK Downloads page to download the latest binary package for Java 17 by using the wget command:

sudo wget

Next, extract your downloaded file with the command below:

sudo tar xvf openjdk-17.0.2_linux-x64_bin.tar.gz

Now move your extracted file to the /opt directory:

sudo mv jdk-17.0.2 /opt/

Step 2 – Configure Java 17 Environment Path on Debian 11

At this point, you need to configure the Java home path by using the following command:

sudo tee /etc/profile.d/ <<EOF
export JAVA_HOME=/opt/jdk-17.0.2
export PATH=\$PATH:\$JAVA_HOME/bin

Source your profile file with the following command:

source /etc/profile.d/

Verify your Java Home path:


Also, you can verify your Java 17 installation on Debian 11 by checking its version:

java -version
openjdk version "17.0.2" 2022-01-18
OpenJDK Runtime Environment (build 17.0.2+8-86)
OpenJDK 64-Bit Server VM (build 17.0.2+8-86, mixed mode, sharing)

Step 3 – Test Java 17 Installation on Debian 11

At this point, we will show you to create a sample project to see that your Java is working correctly on Debian 11.

Create and open the hello world file with your favorite text editor, here we use the vi editor:


Add the following Java code to the file:

public class HelloWorld {

    public static void main(String[] args) {
        // Prints "Hello, World" to the terminal window.
        System.out.println("Hello, World");


When you are done, save and close the file.

Then, compile and run your Java code with the following command:

Hello, World

That’s it, you are done.


At this point, you have learned to download the JDK 17 binary package and configure the environment path for Java and test your installation by creating a sample Hello World project.

Hope you enjoy it. You may be interested in these articles too:

How To Install PHP 8.2 on Debian 11

Set up PHP ionCube Loader on Debian 11

Newsletter Updates

Enter your email address below and subscribe to our newsletter

Stay informed and not overwhelmed, subscribe now!