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.
Step2: Check Version.
Once the installation is complete, we can check Oracle Java version with this command:
java -version
Check Java compiler version.
javac -version
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
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.
Thansk a lot. It is very clear.
Now what?
I have followed the instructions on a RPi 3 raspbian jessie, rebooted but when I try to open a .jnlp file I get the text on an editor screen.
I can’t seem to link this file type to java. Is it not possible to use in Pixel?
Thank you!
Any chance of an update for RaspbiOs Buster?
Tried the above and it reffers to way too old keys and unabel to locate how to find current keys to add reposoitories…
Cheers
Unfortunately this solution no longer works, but I have posted working instructions here: How do I install UniFi Network Controller and Oracle Java 8 on Raspbian 10 (buster)?