How to install Java 8 on Debian Jessie

Oracle Java 8 required by some programs and it is not available on Debian archive due to licensing issues.

To install Java 8 on Debian Jessie with minimum effort, you can use WebUpd8’s Java PPA repositories. Follow the steps below:

echo "deb xenial main" | \
  sudo tee /etc/apt/sources.list.d/webupd8team-java.list
echo "deb-src xenial main" | \
  sudo tee -a /etc/apt/sources.list.d/webupd8team-java.list
sudo apt-key adv --keyserver hkp:// --recv-keys EEA14886
sudo apt-get update
sudo apt-get install oracle-java8-installer

After installation, you can check the java version:

$ javac -version
javac 1.8.0_91

If you can see the version number 1.8.XX, Java 8 installation completed.

If there are other Java/JDK packages on your system, you need to select the default one. Selection can be made with update-alternatives command but WebUpd8 repositories also includes a small package which makes setting Java 8 as default more easily. You just need to install the oracle-java8-set-default package:

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

You can also install openjdk 8 version from jessie backports archive.

To do this:

  • Add jessie-backports into apt if it is not added previously:
echo "deb jessie-backports main" | \
      sudo tee --append /etc/apt/sources.list.d/jessie-backports.list > /dev/null
  • Update apt package database:
sudo apt-get update
  • Install related packages:
sudo apt-get install -t jessie-backports openjdk-8-jdk
  • And optionally, set default java version to newly installed 1.8:
sudo update-java-alternatives -s java-1.8.0-openjdk-amd64