Cyberithub

How to Install Java 17 (OpenJDK 17) on Debian 11 (Bullseye)

Advertisements

In this article, I will take you through the steps to install Java 17 (OpenJDK 17) on Debian 11. Java is a very popular high level programming language used to develop mobile application, web application, desktop application, Games etc. It is probably one of the most widely used programming language across the globe. With the release of JDK 17, lot of new features and support are added into the framework which will further enhance the applicability and usage of this programming language.

Some New Added Features

  • New API for Accessing Large Icons
  • DatagramSocket Can Be Used Directly to Join Multicast Groups
  • Add support for UserDefinedFileAttributeView on macOS
  • Modernization of Ideal Graph Visualizer
  • Source Details in Error Messages
  • macOS on ARM Early Access Available
  • Provide Support for Specifying a Signer in Keytool -genkeypair Command
  • New SunPKCS11 configuration properties
  • SunJCE Provider Supports KW and KWP Modes With AES Cipher
  • Configurable Extensions With System Properties
  • Unified Logging Supports Asynchronous Log Flushing
  • Experimental Compiler Blackholes Support
  • New Class Hierarchy Analysis Implementation in the HotSpot JVM
  • Hex Formatting and Parsing Utility
  • System Property for Native Character Encoding Name
  • Add java.time.InstantSource
  • New Page for "New API" and Improved "Deprecated" Page. More on Java 17 Release Notes.

How to Install Java 17 (OpenJDK 17) on Debian 11 (Bullseye)

How to Install Java 17 (OpenJDK 17) on Debian 11 (Bullseye)

Also Read: How to Install ProtonVPN on Ubuntu 20.04 LTS (Focal Fossa)

Step 1: Prerequisites

a) You should have a running Debian 11(Bullseye) System.

b) You should have sudo or root access to run privileged commands.

c) You should have apt utility available in your System.

 

Step 2: Update Your Server

You can choose to download and install all the latest available updates from Debian repo by using apt-get update command as shown below. If any of the packages needs to be upgraded then you can also use apt-get upgrade command.

root@debian:~# apt-get update
Hit:1 https://download.docker.com/linux/debian bullseye InRelease
Hit:2 http://deb.debian.org/debian bullseye InRelease
Hit:3 http://deb.debian.org/debian bullseye-updates InRelease
Hit:4 http://security.debian.org/debian-security bullseye-security InRelease
Reading package lists... Done

 

Step 3: Search the Package

You can search for Java 17 package to check if it is available in the Debian repo by running apt-cache search openjdk | grep 17 command as shown below.

root@debian:~# 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

 

Step 4: Install Java 17

There are multiple ways to install Java in which we will see the most preferred way of installation. Basically it is preferred to install either from Debian Repo or using standalone Debian package. We will see both the ways.

a) From Debian Repo

This is probably one of the most preferred method to install not only the Java package but all other packages as well which are available from Debian repo. You can just use apt package manager to download and install the specific Java version using below command.

root@debian:~# apt install openjdk-17-jdk openjdk-17-jre
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages were automatically installed and are no longer required:
libaribb24-0 libcddb2 libdouble-conversion3 libdvbpsi10 libebml5 libixml10 liblzo2-2 libmad0 libmatroska7 libmd4c0 libopenmpt-modplug1 libpcre2-16-0
libplacebo72 libprotobuf-lite23 libproxy-tools libqt5core5a libqt5dbus5 libqt5gui5 libqt5network5 libqt5svg5 libqt5widgets5 libqt5x11extras5
libresid-builder0c2a libsdl-image1.2 libsdl1.2debian libsidplay2 libspatialaudio0 libupnp13 libva-wayland2 libvlc-bin libvlc5 libvlccore9 libvncclient1
libxcb-composite0 libxcb-xinerama0 libxcb-xinput0 qt5-gtk-platformtheme qttranslations5-l10n vlc-bin vlc-data vlc-l10n vlc-plugin-access-extra
vlc-plugin-base vlc-plugin-notify vlc-plugin-qt vlc-plugin-samba vlc-plugin-skins2 vlc-plugin-video-output vlc-plugin-video-splitter
vlc-plugin-visualization
Use 'apt autoremove' to remove them.
The following additional packages will be installed:
libice-dev libpthread-stubs0-dev libsm-dev libx11-dev libxau-dev libxcb1-dev libxdmcp-dev libxt-dev openjdk-17-jdk-headless openjdk-17-jre-headless
x11proto-dev xorg-sgml-doctools xtrans-dev
Suggested packages:
libice-doc libsm-doc libx11-doc libxcb-doc libxt-doc openjdk-17-demo openjdk-17-source visualvm fonts-ipafont-gothic fonts-ipafont-mincho
fonts-wqy-microhei | fonts-wqy-zenhei fonts-indic
The following NEW packages will be installed:
libice-dev libpthread-stubs0-dev libsm-dev libx11-dev libxau-dev libxcb1-dev libxdmcp-dev libxt-dev openjdk-17-jdk openjdk-17-jdk-headless openjdk-17-jre
openjdk-17-jre-headless x11proto-dev xorg-sgml-doctools xtrans-dev
0 upgraded, 15 newly installed, 0 to remove and 199 not upgraded.
Need to get 280 MB of archives.
After this operation, 443 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
........................................

b) Using DEB Package

This is another method where you need to go to Oracle official website and download Java 17 using wget utility as shown below. This will download the deb package in local system directory.

root@debian:~# wget https://download.oracle.com/java/17/latest/jdk-17_linux-x64_bin.deb
--2022-04-13 03:37:28-- https://download.oracle.com/java/17/latest/jdk-17_linux-x64_bin.deb
Resolving download.oracle.com (download.oracle.com)... 49.44.204.29
Connecting to download.oracle.com (download.oracle.com)|49.44.204.29|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 155456144 (148M) [text/plain]
Saving to: ‘jdk-17_linux-x64_bin.deb’

jdk-17_linux-x64_bin.deb 100%[============================================================================>] 148.25M 11.8MB/s in 12s

2022-04-13 03:37:40 (12.7 MB/s) - ‘jdk-17_linux-x64_bin.deb’ saved [155456144/155456144]

Then install Java 17 package by using apt install ./jdk-17_linux-x64_bin.deb command as shown below.

root@debian:~# apt install ./jdk-17_linux-x64_bin.deb
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Note, selecting 'jdk-17' instead of './jdk-17_linux-x64_bin.deb'
The following NEW packages will be installed:
jdk-17
0 upgraded, 1 newly installed, 0 to remove and 196 not upgraded.
After this operation, 317 MB of additional disk space will be used.
Get:1 /root/jdk-17_linux-x64_bin.deb jdk-17 amd64 17.0.2-ga [155 MB]
Selecting previously unselected package jdk-17.
(Reading database ... 143696 files and directories currently installed.)
Preparing to unpack /root/jdk-17_linux-x64_bin.deb ...
Unpacking jdk-17 (17.0.2-ga) ...
Setting up jdk-17 (17.0.2-ga) ...

 

Step 5: Check Version

After successful installation, you can check the java version by using java --version command as shown below.

root@debian:~# java --version
openjdk 17.0.2 2022-01-18
OpenJDK Runtime Environment (build 17.0.2+8-Debian-1deb11u1)
OpenJDK 64-Bit Server VM (build 17.0.2+8-Debian-1deb11u1, mixed mode, sharing)

 

Step 6: Configure Java(Optional)

In case if you see Java path are not set then you can set it using below export command. But please keep in mind that this is just the temporary way to set the JAVA_HOME and PATH variables. If you want to make it permanent then put this entry in ~/.bash_profile or ~/.bashrc.

root@debian:~# export JAVA_HOME=/opt/jdk17
root@debian:~# export PATH=$PATH:$JAVA_HOME/bin

 

Step 7: Uninstall Java 17

If you ever decide to uninstall Java 17 package from the system then depending on the method you chose to install, you have to follow the below uninstallation method.

a) When installed from Debian Repo

If you installed the package from Debian repo then use below apt remove command to uninstall Java 17 from your System.

root@debian:~# apt remove openjdk-17-jdk openjdk-17-jre
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages were automatically installed and are no longer required:
libaribb24-0 libcddb2 libdouble-conversion3 libdvbpsi10 libebml5 libice-dev libixml10 liblzo2-2 libmad0 libmatroska7 libmd4c0 libopenmpt-modplug1
libpcre2-16-0 libplacebo72 libprotobuf-lite23 libproxy-tools libpthread-stubs0-dev libqt5core5a libqt5dbus5 libqt5gui5 libqt5network5 libqt5svg5
libqt5widgets5 libqt5x11extras5 libresid-builder0c2a libsdl-image1.2 libsdl1.2debian libsidplay2 libsm-dev libspatialaudio0 libupnp13 libva-wayland2
libvlc-bin libvlc5 libvlccore9 libvncclient1 libx11-dev libxau-dev libxcb-composite0 libxcb-xinerama0 libxcb-xinput0 libxcb1-dev libxdmcp-dev libxt-dev
openjdk-17-jdk-headless qt5-gtk-platformtheme qttranslations5-l10n vlc-bin vlc-data vlc-l10n vlc-plugin-access-extra vlc-plugin-base vlc-plugin-notify
vlc-plugin-qt vlc-plugin-samba vlc-plugin-skins2 vlc-plugin-video-output vlc-plugin-video-splitter vlc-plugin-visualization x11proto-dev
xorg-sgml-doctools xtrans-dev
Use 'apt autoremove' to remove them.
The following packages will be REMOVED:
openjdk-17-jdk openjdk-17-jre
0 upgraded, 0 newly installed, 2 to remove and 199 not upgraded.
After this operation, 568 kB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 145285 files and directories currently installed.)
Removing openjdk-17-jdk:amd64 (17.0.2+8-1~deb11u1) ...
Removing openjdk-17-jre:amd64 (17.0.2+8-1~deb11u1) ...
Processing triggers for hicolor-icon-theme (0.17-2) ...

b) When Installed from DEB Package

If you have installed Java 17 from standalone Debian package then to uninstall you need to use apt remove jdk-17 command as shown below.

root@debian:~# apt remove jdk-17
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages were automatically installed and are no longer required:
libc6-i386 libc6-x32
Use 'apt autoremove' to remove them.
The following packages will be REMOVED:
jdk-17
0 upgraded, 0 newly installed, 1 to remove and 196 not upgraded.
After this operation, 317 MB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 144172 files and directories currently installed.)
Removing jdk-17 (17.0.2-ga) ...

Leave a Comment