2015年11月09日 环境配置 浏览(210)

如何在linux上使用yum安装JDK?

1.查询Java相关列表,执行如下命令:

yum -y list java*

执行结果:

Loaded plugins: security
CentALT                                                  |  951 B     00:00
atomic                                                   | 3.4 kB     00:00
atomic/primary_db                                        | 943 kB     00:03
base                                                     | 3.7 kB     00:00
base/primary_db                                          | 4.6 MB     00:00
epel                                                     | 4.3 kB     00:00
epel/primary_db                                          | 5.7 MB     00:01
extras                                                   | 3.4 kB     00:00
extras/primary_db                                        |  32 kB     00:00
ius                                                      | 2.2 kB     00:00
ius/primary_db                                           | 157 kB     00:00
updates                                                  | 3.4 kB     00:00
updates/primary_db                                       | 2.0 MB     00:00
Installed Packages
java-1.5.0-gcj.x86_64                      1.5.0.0-29.1.el6             @base
java-1.6.0-openjdk.x86_64                  1:1.6.0.35-1.13.7.1.el6_6    @updates
java_cup.x86_64                            1:0.10k-5.el6                @base
Available Packages
java-1.5.0-gcj-devel.x86_64                1.5.0.0-29.1.el6             base
java-1.5.0-gcj-javadoc.x86_64              1.5.0.0-29.1.el6             base
java-1.5.0-gcj-src.x86_64                  1.5.0.0-29.1.el6             base
java-1.6.0-openjdk.x86_64                  1:1.6.0.36-1.13.8.1.el6_7    updates
java-1.6.0-openjdk-demo.x86_64             1:1.6.0.36-1.13.8.1.el6_7    updates
java-1.6.0-openjdk-devel.x86_64            1:1.6.0.36-1.13.8.1.el6_7    updates
java-1.6.0-openjdk-javadoc.x86_64          1:1.6.0.36-1.13.8.1.el6_7    updates
java-1.6.0-openjdk-src.x86_64              1:1.6.0.36-1.13.8.1.el6_7    updates
java-1.7.0-openjdk.x86_64                  1:1.7.0.91-2.6.2.2.el6_7     updates
java-1.7.0-openjdk-demo.x86_64             1:1.7.0.91-2.6.2.2.el6_7     updates
java-1.7.0-openjdk-devel.x86_64            1:1.7.0.91-2.6.2.2.el6_7     updates
java-1.7.0-openjdk-javadoc.noarch          1:1.7.0.91-2.6.2.2.el6_7     updates
java-1.7.0-openjdk-src.x86_64              1:1.7.0.91-2.6.2.2.el6_7     updates
java-1.8.0-openjdk.x86_64                  1:1.8.0.65-0.b17.el6_7       updates
java-1.8.0-openjdk-debug.x86_64            1:1.8.0.65-0.b17.el6_7       updates
java-1.8.0-openjdk-demo.x86_64             1:1.8.0.65-0.b17.el6_7       updates
java-1.8.0-openjdk-demo-debug.x86_64       1:1.8.0.65-0.b17.el6_7       updates
java-1.8.0-openjdk-devel.x86_64            1:1.8.0.65-0.b17.el6_7       updates
java-1.8.0-openjdk-devel-debug.x86_64      1:1.8.0.65-0.b17.el6_7       updates
java-1.8.0-openjdk-headless.x86_64         1:1.8.0.65-0.b17.el6_7       updates
java-1.8.0-openjdk-headless-debug.x86_64   1:1.8.0.65-0.b17.el6_7       updates
java-1.8.0-openjdk-javadoc.noarch          1:1.8.0.65-0.b17.el6_7       updates
java-1.8.0-openjdk-javadoc-debug.noarch    1:1.8.0.65-0.b17.el6_7       updates
java-1.8.0-openjdk-src.x86_64              1:1.8.0.65-0.b17.el6_7       updates
java-1.8.0-openjdk-src-debug.x86_64        1:1.8.0.65-0.b17.el6_7       updates
java-dirq.noarch                           1.4-1.el6                    epel
java-dirq-javadoc.noarch                   1.4-1.el6                    epel
java-sleep.noarch                          2.1-6.el6                    epel
java-sleep-javadoc.noarch                  2.1-6.el6                    epel
java_cup-javadoc.x86_64                    1:0.10k-5.el6                base
java_cup-manual.x86_64                     1:0.10k-5.el6                base
javacc.x86_64                              4.1-0.5.el6                  base
javacc-demo.x86_64                         4.1-0.5.el6                  base
javacc-manual.x86_64                       4.1-0.5.el6                  base
javassist.noarch                           3.9.0-6.el6                  base
javassist-javadoc.noarch                   3.9.0-6.el6                  base
javastroke.x86_64                          0.5.1-24.el6                 epel
javatar.noarch                             2.5-5.el6                    epel
javatar-javadoc.noarch                     2.5-5.el6                    epel

2.选择对应的JDK版本进行安装,必须root用户登录

yum -y install java-1.6.0-openjdk*

3.验证JDK是否安装成功

java -version

执行结果:

[root@iZ94uphqp9lZ ~]# java -version
java version "1.6.0_35"
OpenJDK Runtime Environment (IcedTea6 1.13.7) (rhel-1.13.7.1.el6_6-x86_64)
OpenJDK 64-Bit Server VM (build 23.25-b01, mixed mode)

4.JDK默认安装目录

/usr/lib/jvm

5.存在多个JDK安装目录时如何指定某个JDK?

/etc/alternatives/java 指定一个JDK被/usr/bin/java设定为JDK环境。

用户头像