Step 1
apt install wget libasound2 libasound2-data
Step 2
wget \
--header "Cookie: oraclelicense=accept-securebackup-cookie" \
--no-check-certificate \
--no-cookies \
https://download.oracle.com/otn-pub/java/jdk/13.0.2+8/d4173c853231432d94f001e99d882ca7/jdk-13.0.2_linux-x64_bin.deb
It is the URL for Oracle Java 13.0.2.
You can get the URL of the latest version here: oracle.com/java/technologies/javase-jdk13-downloads.html
Step 3
dpkg -i jdk-13.0.2_linux-x64_bin.deb
If you used a custom URL on the Step 2, then adjust the file name for the dpkg
command.
Step 4
update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk-13.0.2/bin/java 2
update-alternatives --config java
update-alternatives --install /usr/bin/jar jar /usr/lib/jvm/jdk-13.0.2/bin/jar 2
update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk-13.0.2/bin/javac 2
update-alternatives --set jar /usr/lib/jvm/jdk-13.0.2/bin/jar
update-alternatives --set javac /usr/lib/jvm/jdk-13.0.2/bin/javac
Replace 13.0.2 with your version.
Step 5
Check the installation:
java -version
Step 6
Create /etc/profile.d/jdk.sh
with the following contents:
export DERBY_HOME=/usr/lib/jvm/jdk-13.0.2/db
export J2REDIR=/usr/lib/jvm/jdk-13.0.2
export J2SDKDIR=/usr/lib/jvm/jdk-13.0.2
export JAVA_HOME=/usr/lib/jvm/jdk-13.0.2
export PATH=$PATH:/usr/lib/jvm/jdk-13.0.2/bin:/usr/lib/jvm/jdk-13.0.2/db/bin
Step 7
source /etc/profile.d/jdk.sh