Install Oracle Java SE Development Kit 12 in Ubuntu

Java SE Development Kit 12 is provided by Oracle Corporation. At the time of writing the article, the latest stable release of Oracle Java SE Development Kit 12 is 12.0.2. Java is a programming language developed by James Gosling of Sun Microsystems in the year 1995. We already have OpenJDK package available in standard Ubuntu repository. In this article, we would discuss how to install Oracle Java SE Development Kit 12 in Ubuntu.

Install Oracle Java SE Development Kit 12 in Ubuntu

We have to first download the relevant package (.deb) file from the Oracle’s official website. On the web page, you would also see a .tar.gz package file. Although you can install Oracle Java through both the packages but we would stick with .deb package in this article.

Choose the one available for Linux – jdk-12.0.2_linux-x64_bin.deb after accepting the license agreement. Once the file gets downloaded, you need to run the following command in terminal.

Note: Following operations would require you to have superuser privileges. In case you don’t have one, then contact your System Administrator for assistance.

sudo dpkg -i jdk-12.0.2_linux-x64_bin.deb

where,

dpkg is the debian package manager,
-i is for installation.

This will successfully install the .deb package.

There are times, when more than one package is installed on a single system for same set of functions. In such a scenario, you would have to provide a preference among installed programs. We can solve this issue through Debian’s alternative system. This is executed through command-line utility update-alternatives which maintains symbolic links for determining the default programs as per users’ preference.

Hence, run the following in terminal –

sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk-12.0.2/bin/javac 1

sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk-12.0.2/bin/java 1

Above code will also work if your system doesn’t recognize command java -version in your terminal. If you have multiple programs installed then choose the default one through –

sudo update-alternatives --config javac

sudo update-alternatives --config java

Once you are done with the installation process, run the following in terminal –

java -version

and it will return with the output –

java version "12.0.2" 2019-07-16
Java(TM) SE Runtime Environment (build 12.0.2+10)
Java HotSpot(TM) 64-Bit Server VM (build 12.0.2+10, mixed mode, sharing)

In conclusion, we have discussed how to install Oracle Java SE Development Kit 12 in Ubuntu distribution.

Similar Posts