OpenJDK-8 is the abbreviation of the “Open Java Development Kit” standard edition of the Java platform. It can be installed on the latest release of Debian known as Debian Bookworm.
OpenJDK-8 contains the libraries and functions that are being used by Java applications. It can also be used to design Java-based algorithms or applications.
In this post, we will go through the most convenient methods of installing OpenJDK-8 in the latest release of Debian.
What is OpenJDK-8 and its features?
The JDK-8 is a Java project that was designed to complete the open-source reference implementation of the JAVA SE 8 specifications.
The major features of the OpenJDK-8 are:
- Many Java applications, frameworks, and libraries are compatible with the OpenJDK-8
- It is being used in different production environments because of its stability and reliability feature
- Regular security updates are provided to the users of OpenJDK-8 which ensures the security of their information
- OpenJDK-8 has a strong community of developers and enthusiastic users who provide active support for OpenJDK-8
How to Install OpenJDK-8 on Debian 12?
OpenJDK-8 is developed by Oracle and its binaries are available for most operating systems including Linux, Windows, and MacOS. In this section, the installation method of OpenJDK-8 has been explained for the recent release of Debian by the convenient steps.
Launch the terminal of Debian 12 and execute the commands in the below-mentioned steps to install OpenJDK-8.
Step 1: Update the Packages of Debian 12
First, ensure all the packages are up to date by running the update command:
$ sudo apt update -y
The output is indicating that 16 packages can be upgraded by executing the upgrade command:
$ sudo apt upgrade -y
Now all the packages are up to date.
Step 2: Download the OpenJDK-8 on Debian 12
OpenJDK-8 is a pretty old release of Java, therefore, it is not available on the official repository of Debian 12. (Debian 12 official repository contains the 17 releases of Java)
The OpenJDK-8 installer can be downloaded from the official website of Oracle by logging in to your Oracle account:
When the download is completed, verify it by navigating to the “Downloads” directory and listing down its contents:
$ cd Downloads && ls
The tar file of “OpenJDK-8” has been successfully downloaded.
Step 3: Extract the OpenJDK-8 Package
Before extracting the downloaded OpenJDK-8 package, create a new directory using the “mkdir” command:
$ sudo mkdir /usr/lib/jvm/
Now extract the downloaded file in the newly created directory of “jvm”:
$ sudo tar -zxvf jdk-8u361-linux-x64.tar.gz -C /usr/lib/jvm/
The downloaded file has been extracted.
Step 4: Install OpenJDK-8 on Debian 12
Finally, install the OpenJDK-8 on Debian 12 by running the command:
$ sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.8.0_361/bin/java 1
Step 5: Display the Version
To confirm the installation, display the version of installed “OpenJDK-8” using the command:
$ java -version
Java version “1.8.0_361” has been installed on Debian 12.
How to Setup the Environmental Variables?
To set up the environmental variables, open the /java/profile.d directory using the text editor:
$ sudo nano /etc/profile.d/java.sh
Now to access the JAVA application anywhere from Debian 12, we will define the $HOME variable as well as the $PATH variable. To do so, paste the below-mentioned lines in the opened file:
export PATH=$PATH:/usr/lib/jvm/jdk1.8.0_361/bin/export JAVA_HOME=/usr/lib/jvm/jdk1.8.0_361/
Exit the nano text editor using the CTRL+X shortcut key after saving the file with CTRL+S. Load the variables by executing the command:
$ source /etc/profile.d/java.sh
To confirm the above changes, display the value of the environment variable:
$ echo $JAVA_HOME
The OpenJDK-8 has been configured successfully.
To install the OpenJDK-8 on Debian 12, download the tar package from the official website of Oracle. The OpenJDK-8 is an older version so it is not available in the Debian 12 repository. This post explains the installation method of the OpenJDK-8 on Debian 12 using the command-line method.