Published October 11, 2017 by

Install JAVA 8 on Ubuntu/Linux (Oracle Java)

Install Java

# sudo add-apt-repository ppa:webupd8team/java
# sudo apt-get update
# sudo apt-get install oracle-java8-installer

Verify Installed Java Version

# java -version

java version "1.8.0_144"
Java(TM) SE Runtime Environment (build 1.8.0_144-b01)
Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)

Setup Java Environment

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

Now add the JAVA_HOME and JRE_HOME environment variable in /etc/environment configuration file using the following command.

# vim /etc/environment

Insert below lines at end of the file

JAVA_HOME=/usr/lib/jvm/java-8-oracle
JRE_HOME=/usr/lib/jvm/java-8-oracle/jre