How To Install Oracle Java on Debian 10 (Buster)
Abstract: The Java 13 has been installed on your system. If you have multiple version’s of Java installed on the same system. Use the following commands to set
Java is a popular programming language for system software development and web application. You need to install the Java Development Kit (JDK) and Java Runtime Environment (JRE) for the setup of the Java development environment. This tutorial will guide you to install Oracle Java 13 version on Debian 10 Buster Linux system.
Step 1 – PrerequisitesFirst of all, log in to Debian 10 Buster system as the sudo user and install some required packages on your Debian system.
sudo -i apt update apt install wget libasound2 libasound2-dataStep 2 – Download Java Debian Package
Download the latest Java SE Development Kit 13 LTS debian file release from its official download page or use following commands to download from command line.
wget --no-cookies --no-check-certificate --header "Cookie: oraclelicense=accept-securebackup-cookie" https://download.oracle.com/otn-pub/java/jdk/13.0.1+9/cec27d702aa74d5a8630c65ae61e4305/jdk-13.0.1_linux-x64_bin.debStep 3 – Install Oracle Java on Debian 10
Now, use the Debian package installer utility (dpkg) to install a downloaded Java package on your system. Simply run the following command on the system terminal.
dpkg -i jdk-13.0.1_linux-x64_bin.deb
The Java 13 has been installed on your system. If you have multiple version’s of Java installed on the same system. Use the following commands to set Java 13 as default version on your system:
update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk-13.0.1/bin/java 2 update-alternatives --config java
Use above command only If there is multiple Java version installed on your Debian 10 Linux system.
After using the above commands, you also need to other binaries to set as default for the JDK installation. Execute the commands to set javac and jar as default:
update-alternatives --install /usr/bin/jar jar /usr/lib/jvm/jdk-13.0.1/bin/jar 2 update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk-13.0.1/bin/javac 2 update-alternatives --set jar /usr/lib/jvm/jdk-13.0.1/bin/jar update-alternatives --set javac /usr/lib/jvm/jdk-13.0.1/bin/javacStep 4 – Verify Java Version
Therefore Java 13 has successfully installed on your Debian 10 Buster system. Now check the currently active Java version by running the following command.
java -version java version "13.0.1" 2019-10-15 Java(TM) SE Runtime Environment (build 13.0.1+9) Java HotSpot(TM) 64-Bit Server VM (build 13.0.1+9, mixed mode, sharing)Step 5 – Configure Java Environment Variables
Most of the Java-based applications uses environment variables to work. Create a script as below. Now set all the required environment variables for Java. This file will automatically reload settings on system reboot.
sudo nano /etc/profile.d/jdk.sh
Now, Add/Update following values:
File: /etc/profile.d/jdk.shexport J2SDKDIR=/usr/lib/jvm/jdk-13.0.1 export J2REDIR=/usr/lib/jvm/jdk-13.0.1 export PATH=$PATH:/usr/lib/jvm/jdk-13.0.1/bin:/usr/lib/jvm/jdk-13.0.1/db/bin export JAVA_HOME=/usr/lib/jvm/jdk-13.0.1 export DERBY_HOME=/usr/lib/jvm/jdk-13.0.1/db
Then save your file and exit. Then load these setting to current active shell also
source /etc/profile.d/jdk.sh
You have successfully installed Java 13.0.1 on Debian 10 Buster Linux system.