1、 检查 系 统 自 带 的 jdk 信息
[root@localhost ~]# rpm -qa|grep java
java-1.4.2-gcj-compat-1.4.2.0-40jpp.115
2、 删除 JDK
[root@localhost ~]# rpm -e --nodeps java-1.4.2-gcj-compat-1.4.2.0-40jpp.115
3、 确认系统已经没有 jdk
[root@localhost ~]# java -version
bash: java: command not found
4、 安装 JDK
[root@localhost ~]# cd /usr/tmp
[root@localhost tmp]# ls
apache-tomcat-6.0.32.tar.gz VMwareTools-7.8.5-156735.tar.gz
httpd-2.2.19.tar.gz vmware-tools-distrib
jdk-6u26-linux-i586-rpm.bin
5、 准备将 JDK 安装在 /usr 目录下,所以先拷贝 jdk 到该目录
[root@localhost tmp]# cp jdk-6u26-linux-i586-rpm.bin /usr
[root@localhost tmp]# cd ..
[root@localhost usr]# ls
bin games jdk-6u26-linux-i586-rpm.bin lib local share tmp
etc include kerberos libexec sbin src X11R6
6、 给 所有用 户 添加可 执 行的 权 限
[root@localhost usr]# chmod +x jdk-6u26-linux-i586-rpm.bin
7、 执行 jdk 安装文件, 此 时 会生成文件 jdk-6u26-linux-i586.rpm
[root@localhost usr]# ./jdk-6u26-linux-i586-rpm.bin
Unpacking...
Checksumming...
Extracting...
UnZipSFX 5.50 of 17 February 2002, by Info-ZIP ([email protected]).
inflating: jdk-6u26-linux-i586.rpm
inflating: sun-javadb-common-10.6.2-1.1.i386.rpm
inflating: sun-javadb-core-10.6.2-1.1.i386.rpm
inflating: sun-javadb-client-10.6.2-1.1.i386.rpm
inflating: sun-javadb-demo-10.6.2-1.1.i386.rpm
inflating: sun-javadb-docs-10.6.2-1.1.i386.rpm
inflating: sun-javadb-javadoc-10.6.2-1.1.i386.rpm
Preparing... ########################################### [100%]
1:jdk ########################################### [100%]
Unpacking JAR files...
rt.jar...
jsse.jar...
charsets.jar...
tools.jar...
localedata.jar...
plugin.jar...
javaws.jar...
deploy.jar...
Installing JavaDB
Preparing... ########################################### [100%]
1:sun-javadb-common ########################################### [ 17%]
2:sun-javadb-core ########################################### [ 33%]
3:sun-javadb-client ########################################### [ 50%]
4:sun-javadb-demo ########################################### [ 67%]
5:sun-javadb-docs ########################################### [ 83%]
6:sun-javadb-javadoc ########################################### [100%]
Java(TM) SE Development Kit 6 successfully installed.
Product Registration is FREE and includes many benefits:
* Notification of new versions, patches, and updates
* Special offers on Oracle products, services and training
* Access to early releases and documentation
Product and system data will be collected. If your configuration
supports a browser, the JDK Product Registration form will
be presented. If you do not register, none of this information
will be saved. You may also register your JDK later by
opening the register.html file (located in the JDK installation
directory) in a browser.
For more information on what data Registration collects and
how it is managed and used, see:
http://java.sun.com/javase/registration/JDKRegistrationPrivacy.html
Press Enter to continue.....
Done.
[root@localhost usr]# ls
bin sbin
etc share
games src
include sun-javadb-client-10.6.2-1.1.i386.rpm
java sun-javadb-common-10.6.2-1.1.i386.rpm
jdk-6u26-linux-i586.rpm sun-javadb-core-10.6.2-1.1.i386.rpm
jdk-6u26-linux-i586-rpm.bin sun-javadb-demo-10.6.2-1.1.i386.rpm
kerberos sun-javadb-docs-10.6.2-1.1.i386.rpm
lib sun-javadb-javadoc-10.6.2-1.1.i386.rpm
libexec tmp
local X11R6
8、 将 jdk-6u26-linux-i586.rpm 给所有用户分配执行权限
[root@localhost usr]# chmod +x jdk-6u26-linux-i586.rpm
9、 执行 rpm 文件,提示 jdk 已经被安装成功。按照其他的手顺应该是到这一步才算安装成功,不知道是不是最新版本直接执行 bin 文件时就直接安装成功了,这个目前不太清楚。
[root@localhost usr]# rpm -ivh jdk-6u26-linux-i586.rpm
Preparing... ########################################### [100%]
package jdk-1.6.0_26-fcs is already installed
10、 测试 java , javac 命令是否可用。
[root@localhost usr]# java -version
java version "1.6.0_26"
Java(TM) SE Runtime Environment (build 1.6.0_26-b03)
Java HotSpot(TM) Client VM (build 20.1-b02, mixed mode, sharing)
如果要让 jdk 让所有用户使用,必须在 etc/profile 中只是环境变量:
设 置 环 境 变 量 。
#vim /etc/profile
在最后面加入
#set java environment
JAVA_HOME=/usr/java/jdk1.6.0_26
CLASSPATH=.: $ JAVA_HOME/lib.tools.jar
PATH= $ JAVA_HOME/bin: $ PATH
export JAVA_HOME CLASSPATH PATH
保存退出。