This guide will walk you through how to manually install Oracle JDK 12 on Debian 9.8/Ubuntu 18.04. As much you can install the open-source Oracle Java JDK 12 automatically using package manager as demonstrated in our previous guide, Install Oracle Java 12 on Ubuntu 18.04/Debian 9.8, you can as well install it from the official repository as shown in this guide.
Install Oracle Java 12 on Debian 9.8/Ubuntu 18.04
Download Oracle Java 12
Navigate to Oracle Java 12 downloads page and download the official Oracle Java 12 package for Debian based systems. You can however grab the download link and download it using wget if you are downloading it to a remote server.
wget --no-check-certificate -c --header "Cookie: oraclelicense=accept-securebackup-cookie" https://download.oracle.com/otn-pub/java/jdk/12.0.1+12/69cfe15208a647278a19ef0990eea691/jdk-12.0.1_linux-x64_bin.deb
Install Oracle Java 12 on Debian 9.8/Ubuntu 18.04
Once the download is done, run the installation by executing the command below;
sudo apt install ./jdk-12.0.1_linux-x64_bin.deb
Set Java 12 Default Location
In order to configure Oracle Java 12 default locations on Debian 9.8/Ubuntu 18.04, run the command below;
sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk-12.0.1/bin/java" 0
sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/jdk-12.0.1/bin/javac" 0
sudo update-alternatives --install "/usr/bin/jar" "jar" "/usr/lib/jvm/jdk-12.0.1/bin/jar" 0
Oracle Java 12 is now installed. You can verify its version by running the command below;
java --version
java 12.0.1 2019-04-16
Java(TM) SE Runtime Environment (build 12.0.1+12)
Java HotSpot(TM) 64-Bit Server VM (build 12.0.1+12, mixed mode, sharing)
Create JAVA_HOME Environment Variable
To create Oracle Java 12 home environment variable, edit the environment variables configuration file and add the line below;
vim /etc/environment
JAVA_HOME="/usr/lib/jvm/jdk-12.0.1"
Reload the environment variables using the command below;
source /etc/environment
Verify the Environment Variable
echo $JAVA_HOME
/usr/lib/jvm/jdk-12.0.1
That is all about how to install Oracle Java 12 on Debian 9.8/Ubuntu 18.04.
Thanks! all guide is working.
Why to disable certificate using –no-check-certificate? Because I’m trying to “apt upgrade” and it’s rejecting with http://ppa.launchpad.net/linuxuprising/java/ubuntu bionic InRelease indicating is not signed.
How can I fix this “little detail”?
Thank you, I find very useful tips on your site.
Thank you Brigitte. We appreciate.