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 Stretch Linux system.
Step 1 – Prerequsities
First of all, Login 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-data
Step 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.deb
Step 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. Now, If you have multiple Java installed on the same system. You can set the Java 13 default version on your system using belwo:
update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk-13.0.1/bin/java 2 update-alternatives --config java
The above command If there are more than one Java version installed.
There are some other binaries to set as default for 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/javac
Step 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:
export 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
You have successfully installed Java 13.0.1 on Debian 10 Buster Linux system.