原文出处:
http://tecadmin.net/install-oracle-java-8-jdk-8-ubuntu-via-ppa/
经验证非常正确,非常容易操作。
Oracle JAVA 8 Stable release has been released on Mar,18 2014 and available to download and install onofficial download page. Oracle Java PPA for Ubuntu and LinuxMint is being maintained by Webupd8 Team. JAVA 8 is released with many of new features and security updates, read more about whats new in Oracle Java 8.
This article will help you to Install Oracle JAVA 8 (JDK/JRE 8u91) on Ubuntu 16.04, 15.10, 14.04 & 12.04 LTS and 10.04 and LinuxMint systems using PPA. To Install Java 8 in CentOS, Redhat and Fedora read This Article.
First you need to add webupd8team Java PPA repository in your system and install Oracle Java 8 using following set of commands.
$ sudo add-apt-repository ppa:webupd8team/java $ sudo apt-get update $ sudo apt-get install oracle-java8-installer
After successfully installing oracle Java using above step verify installed version using following command.
rahul@tecadmin:~$ java -version java version "1.8.0_91" Java(TM) SE Runtime Environment (build 1.8.0_91-b14) Java HotSpot(TM) 64-Bit Server VM (build 25.91-b14, mixed mode)
In Webupd8 ppa repository also providing a package to set environment variables, Install this package using following command.
$ sudo apt-get install oracle-java8-set-default
References:
https://launchpad.net/~webupd8team/+archive/java
增加一个多版本JAVA的切换命令,出处sackover flow 网站:http://stackoverflow.com/questions/25549492/install-jdk8-in-ubuntu-14-04
should show you using Oracle Java 8. If not, or if you want to use a different version - run update-java-alternatives
with something like,
sudo update-java-alternatives -s java-8-oracle
or
sudo update-java-alternatives -s java-7-oracle
补充,对于在docker中安装jdk8,而又没有命令add-apt-repository 的情况,可以采用如下操作:
Installing Oracle JDK
sudo apt-get install python-software-properties
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
Oracle JDK 6(旧版本)
sudo apt-get install oracle-java6-installer
Oracle JDK 7(较新的稳定版本)
sudo apt-get install oracle-java7-installer
Oracle JDK 8(最新预览版本)
sudo apt-get install oracle-java8-installer