Install Oracle Java 8 on Debian Jessie and Raspbian Jessie Via PPA

In a previous tutorial, I showed you how to install Oracle Java 8 on Ubuntu, Linux Mint and Elementary OS via PPA. You can also use the same PPA to install Oracle Java 8 on Debian Jessie and Raspbian Jessie. But the process of adding PPA to Debian and Raspbian is a little different. So I dedicated a whole article to guide you through the process.

Install Oracle Java 8 on Debian Jessie and Raspbian Jessie

Step1: Add the PPA and install Oracle Java 8

First remove OpenJDK

sudo apt-get remove openjdk*

Next, fetch the GPG signing key for this PPA with this command:

sudo apt-key adv --recv-key --keyserver keyserver.ubuntu.com EEA14886

Then, edit /etc/apt/sources.list file.

sudo nano /etc/apt/sources.list

Append the following two lines at the end of the file.

deb http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main 
deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main

Save and close the file. Now update local package index and install Oracle Java 8.

sudo apt-get update

sudo apt-get install oracle-java8-installer

oracle-java8-installer is not the Java binary. Instead it’s a installer that can fetch Java binary from Oracle website and then install it on your Debian or Raspbian machine.

Install Oracle Java 8 on Debian

Step2: Check Version.

Once the installation is complete, we can check Oracle Java version with this command:

java -version

Install Oracle Java 8 on Debian and Raspbian

Check Java compiler version.

javac -version

Install Oracle Java 8 on Debian and Raspbian

Step3: Set Java Environment Variables

In order to let Debian or Raspbian to know where Java JDK and JRE is located, we need to set environment variables. Run the following command to set Java environment variables.

sudo apt-get install oracle-java8-set-default

Once installed, there will be two new files under /etc/profile.d/ directory: jdk.csh and jdk.sh. These two files are shell scripts that contains commands to set 5 enviroment variables. We can use cat command to check out its content.

cat /etc/profile.d/jdk.sh

Output:

export J2SDKDIR=/usr/lib/jvm/java-8-oracle
export J2REDIR=/usr/lib/jvm/java-8-oracle/jre
export PATH=$PATH:/usr/lib/jvm/java-8-oracle/bin:/usr/lib/jvm/java-8-oracle/db/bin:/usr/lib/jvm/java-8-oracle/jre/bin
export JAVA_HOME=/usr/lib/jvm/java-8-oracle
export DERBY_HOME=/usr/lib/jvm/java-8-oracle/db

What we need to do is to use the source command to execute the /etc/profile bash shell script to let these environment variables to take effect.

source /etc/profile

source is used specifically to execute commands in a shell script. If you are using the bash shell, then source can be abbreviated to a dot like this:

. /etc/profile

This has the same effect. Now you can check these 5 environment variables like below:

echo $JAVA_HOME

Install Oracle Java 8 on Debian and Raspbian

As you can see, the process of installing Oracle Java 8 on Debian Jessie and Raspbian Jessie via PPA is roughly the same, except that the method of adding PPA is little bit different.

Rate this tutorial
[Total: 19 Average: 4.5]