$~ echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu xenial main" | tee /etc/apt/sources.list.d/webupd8team-java.list
$~ echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu xenial main" | tee -a /etc/apt/sources.list.d/webupd8team-java.list
$~ apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys EEA14886
$~ apt-get update
$~ apt-get install oracle-java8-installer
如果系统有多个版本的java,可以通过以下方式设置:
update-alternatives --config java