Programster's Blog

Tutorials focusing on Linux, programming, and open-source

Debian 8 - Install Oracle Java

Execute the following script to install Oracle's version of Java.

#!/bin/bash
sudo echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" | \
sudo tee /etc/apt/sources.list.d/webupd8team-java.list

sudo echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" | \
sudo tee -a /etc/apt/sources.list.d/webupd8team-java.list

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys EEA14886
sudo apt-get update
sudo apt-get install oracle-java8-installer -y
exit

If you need to automatically accept the licence agreement, such as for a Dockerfile, then you will need to add:

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

Checking Version

To check the version of Java that is installed, execute the command below:

java -version

References

Last updated: 16th August 2018
First published: 16th August 2018