How to Manually Install Oracle Java 12 on Debian 9.8/Ubuntu 18.04

|
Last Updated:
|
|

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.

SUPPORT US VIA A VIRTUAL CUP OF COFFEE

We're passionate about sharing our knowledge and experiences with you through our blog. If you appreciate our efforts, consider buying us a virtual coffee. Your support keeps us motivated and enables us to continually improve, ensuring that we can provide you with the best content possible. Thank you for being a coffee-fueled champion of our work!

Photo of author
koromicha
I am the Co-founder of Kifarunix.com, Linux and the whole FOSS enthusiast, Linux System Admin and a Blue Teamer who loves to share technological tips and hacks with others as a way of sharing knowledge as: "In vain have you acquired knowledge if you have not imparted it to others".

4 thoughts on “How to Manually Install Oracle Java 12 on Debian 9.8/Ubuntu 18.04”

Leave a Comment