Oracle Java is a popular programming language and platform for creating and running a variety of applications. If you are using Debian and need to install Oracle Java 17 on Debian, this article will walk you through the installation process step by step. Please keep in mind that Oracle Java must be installed manually on Debian because it is not accessible in the official Debian repositories. In this article, I’ll show you How to Install Oracle Java 17 on Debian step by step procedures.
Table of Contents
Prerequisites
- You should have a Debian 11(Bullseye) system up and running.
- To run
root
commands, you must havesudo
orroot
access.
Step 1: Initial Setup
Make sure your system or server packages are updated to the latest version available.
sudo apt update
sudo apt upgrade -y
Step 2: Search for Java 17 Package
You can search your Debian 11 system to find if Java 17 packages are available in the system repositories.
Execute the below command to search for Java 17.
sudo apt-cache search openjdk | grep 17
If you get the below output you, you are having JRE and JDK repositories available in your Debian system.
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 3: Install Java 17
Execute the below command to install Java JRE.
sudo apt install openjdk-17-jre
You can also install JDK using the below command.
sudo apt install openjdk-17-jdk
Once the installation is complete, you should have Java 17 installed on your Debian 11.
Step 4: Verify Java 17 Installation
Verify the installation using the below command
java --version
You will receive an output similar to the one below.
openjdk 17.0.7 2023-04-18
OpenJDK Runtime Environment (build 17.0.7+7-Debian-1deb11u1)
OpenJDK 64-Bit Server VM (build 17.0.7+7-Debian-1deb11u1, mixed mode, sharing)
Step 5: Configure Environment Variables
To set the Java environment variables, you need add the following lines to your profile to export Java path.
Execute the below command to create a new file in your profile.d
directory or to your bashrc
file, so that each time you open your terminal this file runs.
Now we will add the Path to the profile.
cat <<EOF | sudo tee /etc/profile.d/jdk.sh
export JAVA_HOME=/usr/lib/jvm/jdk-17/
export PATH=\$PATH:\$JAVA_HOME/bin
EOF
echo 'export JAVA_HOME=/usr/local/jdk-17' >> ~/.bashrc
echo 'export PATH=$JAVA_HOME/bin:$PATH' >> ~/.bashrc
These commands will append the export lines to the end of the.bashrc file.
To implement the changes instantly, you must source the.bashrc file. Execute this command:
source ~/.bashrc
The environment variables in your current terminal session will be modified when you source the file. If you do not wish to source it right now, the modifications will be applied the next time you launch a new terminal session.
Step 6: Validate Java Path
Run the following command to validate the JAVA_HOME environment variable:
echo $JAVA_HOME
Also read: You might also find useful our guide on How to Install MongoDB on Debian 11
Conclusion
Finally, installing Oracle Java 17 on Debian entails downloading the relevant package, extracting the files to the desired location, and configuring the necessary environment variables. Users may assure a successful installation and verification of Java 17 on their Debian system by following the step-by-step instructions provided, allowing them to take advantage of its features and capabilities. Please feel free to share your thoughts and feedback in the comment section below.