红联Linux门户
Linux帮助

Ubuntu 16.04安装JDK和Open Jdk

发布时间:2016-05-20 10:19:51来源:linux网站作者:陈三哥

Ubuntu 16.04 安装 JDK 和 Open Jdk默认JDK 安装相对比较轻松,但如果想调整 OpenSdk 版本可就有点儿麻烦, 特别是 OpenJdk7 。常规安装 见下方附录(How to download and install prebuilt OpenJDK packages)


默认JDK 安装:

sudo apt-get update
sudo apt-get install default-jre


Oracle JDK 安装:
设置 PPA

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update

JDK6 :

sudo apt-get install oracle-java6-installer

JDK 7:

sudo apt-get install oracle-java7-installer

JDK 8

sudo apt-get install oracle-java8-installer

OpenJdk 7安装:

sudo add-apt-repository ppa:openjdk-r/ppa 
sudo apt-get update
sudo apt-get install openjdk-7-jdk 

版本之间切换

update-alternatives --config java
update-alternatives --config javac


附:How to download and install prebuilt OpenJDK packages
JDK 8
Debian, Ubuntu, etc.

On the command line, type:

$ sudo apt-get install openjdk-8-jre

The openjdk-8-jre package contains just the Java Runtime Environment. If you want to develop Java programs then please install the openjdk-8-jdk package.
Fedora, Oracle Linux, Red Hat Enterprise Linux, etc.

On the command line, type:

$ su -c "yum install java-1.8.0-openjdk"

The java-1.8.0-openjdk package contains just the Java Runtime Environment. If you want to develop Java programs then install the java-1.8.0-openjdk-devel package.
JDK 7
Debian, Ubuntu, etc.

On the command line, type:

$ sudo apt-get install openjdk-7-jre

The openjdk-7-jre package contains just the Java Runtime Environment. If you want to develop Java programs then install the openjdk-7-jdk package.
Fedora, Oracle Linux, Red Hat Enterprise Linux, etc.

On the command line, type:

$ su -c "yum install java-1.7.0-openjdk"

The java-1.7.0-openjdk package contains just the Java Runtime Environment. If you want to develop Java programs then install the java-1.7.0-openjdk-devel package.
JDK 6
Debian, Ubuntu, etc.

On the command line, type:

$ sudo apt-get install openjdk-6-jre

The openjdk-6-jre package contains just the Java Runtime Environment. If you want to develop Java programs then install the openjdk-6-jdk package.
Fedora, Oracle Linux, Red Hat Enterprise Linux, etc.

On the command line, type:

$ su -c "yum install java-1.6.0-openjdk"

The java-1.6.0-openjdk package contains just the Java Runtime Environment. If you want to develop Java programs then install the java-1.6.0-openjdk-devel package.
BSD Port

For a list of pointers to packages of the BSD Port(http://openjdk.java.net/projects/bsd-port/) for DragonFly BSD, FreeBSD, Mac OS X, NetBSD and OpenBSD, please see the BSD porting Project's wiki page(http://wiki.openjdk.java.net/display/BSDPort/Main).


本文永久更新地址:http://www.linuxdiyf.com/linux/20796.html