HomeDEBIANHow To Install Java 17(OpenJDK) on Debian 11|Debian 10

How To Install Java 17(OpenJDK) on Debian 11|Debian 10

In this guide, we will learn how to install Java 17(OpenJDK) on Debian 11|Debian 10. Programmers may write apps once and run them across several platforms thanks to Java, a high-level, object-oriented programming language and computing platform. This suggests that compiled Java code can run on any platform that accepts Java without needing to be recompiled.Java, Javac, Jar, and many other programming tools are included in the Java Development Kit (JDK).

On September 14, 2021, Java 17 LTS, the most current long-term support release for the Java SE platform, became available.

Cool features available in Java 17

  • A better version of a pseudo-random number generator.
  • In place of the current pipeline’s use of the obsolete OpenGL API, a new rendering pipeline for MacOS leverages the Apple Metal API.
  • Uninstall the experimental AOT and JIT compiler.
  • The classes and interfaces that can extend or implement sealed classes and interfaces are limited.

the elimination of the Remote Method Invocation (RMI) Activation method

  • Remove the Applet API by Deprecating It.
  • Response to Apple’s intention to switch its Macintosh machines from x64 to AArch64 by porting the JDK to MacOS/AArch64.
  • JDK internals is strongly encapsulated.
  • Filters for deserialization with a context.
  • The Java runtime environment’s external function and memory API enable the communication between code and data inside and outside Java projects.

The following steps will guide on installing Java 17(OpenJDK) on Debian 11|Debian 10 successfully.

#1. Install Java 17(OpenJDK) on Debian 11|Debian 10

This guide will demonstrate two ways of installing Java 17 on Debian 11|Debian 10. Choose one that best works for you.

Option 1 – Install Java 17 (OpenJDK 17) on Debian 11|Debian 10 using APT repositories

Java 17 packages exist on the default Debian 11|Debian 10 repositories. Begin by updating your system

sudo apt update
sudo apt upgrade

Once all packages are up to date, find the OpenJDK17 packages:

$ apt-cache search openjdk | grep 17
openjdk-17-dbg - Java runtime based on OpenJDK (debugging symbols)
openjdk-17-demo - Java runtime based on OpenJDK (demos and examples)
openjdk-17-doc - OpenJDK Development Kit (JDK) documentation
openjdk-17-jdk - OpenJDK Development Kit (JDK)
openjdk-17-jdk-headless - OpenJDK Development Kit (JDK) (headless)
openjdk-17-jre - OpenJDK Java runtime, using Hotspot JIT
openjdk-17-jre-headless - OpenJDK Java runtime, using Hotspot JIT (headless)
openjdk-17-jre-zero - Alternative JVM for OpenJDK, using Zero
openjdk-17-source - OpenJDK Development Kit (JDK) source files

Once that is done, OpenJDK 17 is installed by executing the command below.

# Install openJDK JDK 17
sudo apt install openjdk-17-jdk

# Install OpenJDK JRE
sudo apt install openjdk-17-jre

Check the version installed.

$ java -version
openjdk version "17.0.6" 2023-01-17
OpenJDK Runtime Environment (build 17.0.6+10-Debian-1deb11u1)
OpenJDK 64-Bit Server VM (build 17.0.6+10-Debian-1deb11u1, mixed mode, sharing)

Option 2 – Install OpenJDK 17 on Debian 11|Debian 10 using Binary

Download the most recent archive by going to the JDK 17 releases page.

wget https://download.java.net/java/GA/jdk17.0.2/dfd4a8d0985749f896bed50d7138ee7f/8/GPL/openjdk-17.0.2_linux-x64_bin.tar.gz

Using the tar command, extract the OpenJDK 17 archive file that was downloaded.

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

Then, transfer the folder to the /opt directory.

sudo mv jdk-17*/ /opt/jdk17

Now Set up the Java environment:

cat <<EOF | sudo tee /etc/profile.d/jdk.sh
export JAVA_HOME=/opt/jdk17
export PATH=\$PATH:\$JAVA_HOME/bin
EOF

Source your profile:

source /etc/profile.d/jdk.sh

Verify the installation:

$ 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)

Wonderful, Java 17 has been installed successfully on your server.

#2. Test the Java 17 Installation on Debian 11|Debian 10

We have successfully walked through how to install Java 17(OpenJDK) on Debian 11|Debian 10. We now need to test if Java is running perfectly by running a simple Java program.

Create the test program as shown:

tee HelloWorld.java<<EOF
public class HelloWorld {

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

}
EOF

Execute the code with the command:

java HelloWorld.java

Sample Output:

How to install Java 17(OpenJDK)  on Debian 11|Debian 10

Conclusion

With the two procedures we’ve described, you can easily install the most recent OpenJDK.You can now set up software that utilizes Java.

Other tutorials include:

- Advertisment -

Recent posts

LEAVE A REPLY

Please enter your comment!
Please enter your name here