1.查找java相关得列表
[qyf@localhost ~]$ yum -y listjava*
执行结果
[qyf@localhost ~]$ yum -y listjava*
Loaded plugins:fastestmirror
base | 1.1 kB 00:00
base/primary | 995 kB00:00
base 2789/2789
extras | 2.1 kB 00:00
extras/primary_db | 164 kB00:20
updates | 1.9 kB 00:00
updates/primary_db | 422 kB00:01
Available Packages
java-1.4.2-gcj-compat.i386 1.4.2.0-40jpp.115base
java-1.4.2-gcj-compat-devel.i3861.4.2.0-40jpp.115 base
java-1.4.2-gcj-compat-javadoc.i3861.4.2.0-40jpp.115 base
java-1.4.2-gcj-compat-src.i3861.4.2.0-40jpp.115 base
java-1.6.0-openjdk.i3861:1.6.0.0-5.1.13.3.el5_10 updates
java-1.6.0-openjdk-demo.i3861:1.6.0.0-5.1.13.3.el5_10 updates
java-1.6.0-openjdk-devel.i3861:1.6.0.0-5.1.13.3.el5_10 updates
java-1.6.0-openjdk-javadoc.i3861:1.6.0.0-5.1.13.3.el5_10 updates
java-1.6.0-openjdk-src.i3861:1.6.0.0-5.1.13.3.el5_10 updates
java-1.7.0-openjdk.i3861:1.7.0.55-2.4.7.1.el5_10 updates
java-1.7.0-openjdk-demo.i3861:1.7.0.55-2.4.7.1.el5_10 updates
java-1.7.0-openjdk-devel.i3861:1.7.0.55-2.4.7.1.el5_10 updates
java-1.7.0-openjdk-javadoc.i3861:1.7.0.55-2.4.7.1.el5_10 updates
java-1.7.0-openjdk-src.i3861:1.7.0.55-2.4.7.1.el5_10 updates
java_cup.i386 1:0.10-0.k.6jpp.1base
java_cup-javadoc.i386 1:0.10-0.k.6jpp.1base
java_cup-manual.i386 1:0.10-0.k.6jpp.1base
javacc.i386 4.0-3jpp.3base
javacc-demo.i386 4.0-3jpp.3base
javacc-manual.i386 4.0-3jpp.3base
2.使用root用户安装
安装时提醒必须使用root用户,sudo都不行。
[qyf@localhost ~]$ yum -y installjava-1.6.0-openjdk*
执行结果
[qyf@localhost ~]$ yum -y installjava-1.6.0-openjdk*
Loaded plugins:fastestmirror
Loading mirror speeds from cachedhostfile
* base: mirror.bit.edu.cn
* extras:mirror.bit.edu.cn
* updates:centos.ustc.edu.cn
base | 1.1 kB 00:00
base/primary | 995 kB00:07
base 2789/2789
extras | 2.1 kB 00:00
extras/primary_db | 164 kB00:02
updates | 1.9 kB 00:00
updates/primary_db | 422 kB00:07
Setting up Install Process
Resolving Dependencies
--> Running transactioncheck
---> Package java-1.6.0-openjdk.i3861:1.6.0.0-5.1.13.3.el5_10 set to be updated
--> Processing Dependency: jpackage-utils>= 1.7.3-1jpp.2 for package:java-1.6.0-openjdk
--> Processing Dependency: libgif.so.4 forpackage: java-1.6.0-openjdk
--> Processing Dependency: tzdata-java forpackage: java-1.6.0-openjdk
---> Package java-1.6.0-openjdk-demo.i3861:1.6.0.0-5.1.13.3.el5_10 set to be updated
---> Package java-1.6.0-openjdk-devel.i3861:1.6.0.0-5.1.13.3.el5_10 set to be updated
---> Packagejava-1.6.0-openjdk-javadoc.i386 1:1.6.0.0-5.1.13.3.el5_10 set to beupdated
---> Package java-1.6.0-openjdk-src.i3861:1.6.0.0-5.1.13.3.el5_10 set to be updated
--> Running transactioncheck
---> Package giflib.i386 0:4.1.3-7.3.3.el5set to be updated
---> Package jpackage-utils.noarch0:1.7.3-1jpp.3.el5 set to be updated
---> Package tzdata-java.i386 0:2014b-1.el5set to be updated
--> Finished DependencyResolution
Dependencies Resolved
================================================================================
Package Arch VersionRepository
Size
================================================================================
Installing:
java-1.6.0-openjdk i3861:1.6.0.0-5.1.13.3.el5_10 updates 44 M
java-1.6.0-openjdk-demo i3861:1.6.0.0-5.1.13.3.el5_10 updates 2.2 M
java-1.6.0-openjdk-devel i3861:1.6.0.0-5.1.13.3.el5_10 updates 15 M
java-1.6.0-openjdk-javadoc i3861:1.6.0.0-5.1.13.3.el5_10 updates 20 M
java-1.6.0-openjdk-src i3861:1.6.0.0-5.1.13.3.el5_10 updates 39 M
Installing fordependencies:
giflib i386 4.1.3-7.3.3.el5 base 39k
jpackage-utils noarch 1.7.3-1jpp.3.el5 base 60k
tzdata-java i386 2014b-1.el5 updates 172k
Transaction Summary
================================================================================
Install 8 Package(s)
Upgrade 0 Package(s)
Total download size: 120 M
Downloading Packages:
(1/8): giflib-4.1.3-7.3.3.el5.i386.rpm | 39 kB00:00
(2/8):jpackage-utils-1.7.3-1jpp.3.el5.noarch.rpm | 60 kB00:00
(3/8): tzdata-java-2014b-1.el5.i386.rpm | 172kB 00:04
(4/8):java-1.6.0-openjdk-demo-1.6.0.0-5.1.13.3.el5_10.i386.rpm | 2.2 MB00:47
(5/8):java-1.6.0-openjdk-devel-1.6.0.0-5.1.13.3.el5_10.i386.rpm | 15 MB04:25
(6/8):java-1.6.0-openjdk-javadoc-1.6.0.0-5.1.13.3.el5_10.i386.rpm (17%)19% [============ ] 81 kB/s | 3.8 MB 03:19 ETA
最后一行就是在下载jdk了,这里我们安装jdk1.6相关得全部包。
3.确认是否安装成功
[qyf@localhost ~]$ java-version
执行结果
[qyf@localhost ~]$ java-version
java version "1.6.0_30"
OpenJDK Runtime Environment (IcedTea6 1.13.3)(rhel-5.1.13.3.el5_10-i386)
OpenJDK Client VM (build 23.25-b01, mixedmode)
正确显示了jdk版本信息就说明安装成功了。
4.默认情况下jdk安装得路径
/usr/lib/jvm
由于我们得机器可能同时安装好几个版本得jdk,所以在/etc/alternatives目录下会有一个java链接到具体的java命令。而这个/etc/alternatives/java会被/usr/bin/java链接。从而java命令就被设置到了shell环境中。