#Install
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java7-installer
If you see this error,
$ sudo add-apt-repository ppa:webupd8team/java
sudo: add-apt-repository: command not found
Run this.
$ sudo apt-get install software-properties-common
#Version
java -version
# => java version "1.7.0_65"
# => Java(TM) SE Runtime Environment (build 1.7.0_65-b17)
# => Java HotSpot(TM) 64-Bit Server VM (build 24.65-b04, mixed mode)
#Setup
echo export JAVA_HOME=/usr/lib/jvm/java-7-oracle >> ~/.bash_profile
. ~/.bash_profile
env | grep JAVA_HOME
# => JAVA_HOME=/usr/lib/jvm/java-7-oracle