Open Terminal
- Update repository:
sudo add-apt-repository ppa:openjdk-r/ppa
sudo apt update
- Install the jdk-1.8.0 and source
sudo apt install openjdk-8-jdk
sudo apt install openjdk-8-source
- In terminal, set system environmental variable JAVA_HOME and PATH
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk
export PATH=$PATH:$JAVA_HOME/bin
- Check your installation:
javac -version
java -version
Reference: StackOverflow