Install Oracle Java In Debian/ Ubuntu using apt-get

Install Oracle Java In Debian/ Ubuntu using apt-get

Category : How-to

Get Social!

java-logo

Oracle Java, due to Oracle’s license conditions, it quite a pain to install. The problem is that anyone who isn’t Oracle isn’t allowed to distribute the JDK binaries – they have to be downloaded strictly from Oracle. Luckily the guys over at webupd8team have been creative in this area and created and apt-get package that downloads the Java binaries from Oracle, presents the license agreement that you have to accept and and installs Java on the local machine.

Add Java Repository Using apt-add-repository on Ubuntu

We’ll use the apt-add-repository tool in this section to add the webupd8team’s ppa repository to our local apt package manager. This method should be used on Ubuntu – see the next section for Debian.

Before running the command, make sure you’ve got apt-add-repository installed as it’s often missing in the more minimal installations.

apt-get install software-properties-common

Older versions of Ubuntu (13.10 and older) would need a slightly different package:

apt-get install python-software-properties

Once you’ve got the package installed, go ahead and add the ppa Java repository and update your local apt cache with the new available packages.

apt-add-repository ppa:webupd8team/java
apt-get update

Add Java Repository Manually on Debian

If you’re using Debian or would like to manually add and maintain the list of repositories used by your apt installation then use the below commands.

echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu xenial main" | tee /etc/apt/sources.list.d/webupd8team-java.list
echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu xenial main" | tee -a /etc/apt/sources.list.d/webupd8team-java.list
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys EEA14886
apt-get update

This will create a new file containing the repository location in /etc/apt/sources.list.d/webupd8team-java.list

 

Installing Oracle Java

When using this method, the first step of the install process is to download the Oracle Java binaries from Oracle.com. You’ll then need to accept the license agreement and then the installation will begin.

You can automatically accept the license agreement, which is useful when scripting the install where it’s impossible to interact with the process. The first command in the following sections instructs the install to automatically accept the license agreement. If you’d like to read and manually accept the agreement then do not run the first line.

Choose your Java version:

Install Java 7

For Oracle JDK7 use:

echo oracle-java7-installer shared/accepted-oracle-license-v1-1 select true | /usr/bin/debconf-set-selections
apt-get install oracle-java7-installer

Install Java 8

For Oracle JDK8 use:

echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | /usr/bin/debconf-set-selections
apt-get install oracle-java8-installer

 

Java Variables

Finally, you can set the Java variables automatically using another package provided by the webupd8team. Upgrading, say from Java 7 to Java 8 will automatically remove the predecessors package.

apt-get install oracle-java7-set-default

Or

apt-get install oracle-java8-set-default

Scripted Install

See the following for copy and paste scripts for installing:


Leave a Reply

Visit our advertisers

Quick Poll

What type of VPN protocol do you use?

Visit our advertisers