1安装jdk
centos 6.4自带jdk 版本为1.6

命令:java -version
结果:
#java version "1.6.0_24"
OpenJDK Runtime Environment (IcedTea6 1.11.9) (rhel-1.57.1.11.9.el6_4-x86_64)
OpenJDK 64-Bit Server VM (build 20.0-b12, mixed mode)

2.先卸载旧的jdk,先查看安装包
命令:#rpm -ql | grep java
结果:
tzdata-java-2013b-1.el6.noarch
java-1.6.0-openjdk-1.6.0.0-1.57.1.11.9.el6_4.x86_64

卸载
命令:
# rpm -e --nodeps java-1.6.0-openjdk-1.6.0.0-1.57.1.11.9.el6_4.x86_64
# rpm -e --nodeps tzdata-java-2013b-1.el6.noarch

3.下载最新版jdk 7 :http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html(下载rpm格式,直接可安装)

4.配置环境
vim /etc/profile

在最后面加上如下:

  1. export JAVA_HOME=/usr/java/jdk

  2. export CLASSPATH=.:%JAVA_HOME%/lib/dt.jar:%JAVA_HOME%/lib/tools.jar

  3. export PATH=$PATH:$JAVA_HOME/bin

注意:linux环境变量的分隔符是冒号“:”不是分号“;”

5.让系统配置立即生效:source /etc/profile

6.查看版本:java -version



转自http://blog.sina.com.cn/s/blog_9ea389050101dia9.html