/ java

Installing Oracle Java 8 on Ubuntu.

Howdy Folks. Let’s quickly check out Installing Oracle Java 8 on Ubuntu. There are multiple ways this can be done.

1 Using Ubuntu Repositories

Well, if you using Ubuntu, it’s a quite straightforward to install it using the Ubuntu repositories. We are going to use Oracle WebUpd8 repositories here.

For all those, who don’t know, Ubuntu ships with a package manager which can be used to install software packages. Some of these packages are not directly shipped with the Ubuntu, but are available in third-party software package repositories.

sudo add-apt-repository ppa:webupd8team/java

Once, the package repository has been added, we need to instruct Ubuntu to reload the package manager with the new repositories.

sudo apt-get update -y

1.1 Installing Java

Alright, since you have the repository now, you can go ahead and install Java. This one is going to install Oracle Java 8.

sudo apt-get install oracle-java8-installer

1.2 Verifying the install

Let’s just verify the installation.

java -version

2 Manual Installation

There is always ways to install them manually if you come across some issue for some weird reason.

2.1 Downloading Java

The Java binaries are available on the Oracle’s website for downloads and comes in various versions. We are going to pick the .tar.gz version here. This one is for Oracle JDK 8.

wget http://download.oracle.com/otn-pub/java/jdk/8u144-b01/090f390dda5b47b9b721c7dfaa008135/jdk-8u144-linux-x64.tar.gz --no-check-certificate -c --header "Cookie: oraclelicense=accept-securebackup-cookie"

2.2 Unzipping Java to a installation location.

The archive directly contains the binaries you can use, let’s unzip it and store in an appropriate location.

sudo tar xzvf jdk-8u144-linux-x64.tar.gz -C /usr/share/

2.3 Setting the binary location

sudo update-alternatives --install /usr/bin/java java /usr/share/jdk1.8.0_144/bin/java 9999 sudo update-alternatives --install /usr/bin/javac javac /usr/share/jdk1.8.0_144/bin/jav ac 9999

2.4 Updating the default alternative (Optional)

In case you have setup Java earlier and set up the alternatives path manually, you may need to do it again to override your choice. For this, just run the following and choose the selection.

sudo update-alternatives --config java

2.5 Verifying the installation

java --version
Love Hasija

Love Hasija

Full Stack Research Engineer, Software Architect | Helped build next generation software systems | Distributed Systems Fanatic | Open Source Hacker.

Read More