sudo add-apt-repository ppa:webupd8team/java
sudo apt-get -y update
sudo apt-get -y install oracle-java8-installer
sudo vim /etc/environment
Add this at the end of the file
JAVA_HOME="/usr/lib/jvm/java-8-oracle"
source /etc/environment
原文:http://www.cnblogs.com/codingforum/p/7482534.html