Rhel6下JDK1.6.0_26的配置
红帽子下JDK的配置比Ubuntu的要方便些,直接下载,解压,配置环境变量就行了。
1)建立目录/usr/java
将jdk-6u26-linux-i586-rpm.bin拷贝到RHEL下的/usr/java下。
2) 修改文件权限,执行chmod 755 jdk-6u26-linux-i586-rpm.bin
3) 开始安装,执行./ jdk-6u26-linux-i586-rpm.bin
4) 设置环境变量,打开/etc/profile,在文件末尾,done与unset i之间加入如下环境变量配置
JAVA_HOME=/usr/java/jdk1.6.0_26
CLASSPATH=.:$JAVA_HOME/lib.tools.jar
PATH=$JAVA_HOME/bin:$PATH
export JAVA_HOME CLASSPATH PATH
5) 重启终端
6) 验证是否安装成功,执行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)
PS:Redhat Enterprise Linux 6.4 安装Oracle JDK替换OpenJDK
缺省java版本为OpenJDK 1.7:
# java -version
java version "1.7.0_09-icedtea"
OpenJDK Runtime Environment (rhel-2.3.4.1.el6_3-x86_64)
OpenJDK 64-Bit Server VM (build 23.2-b09, mixed mode)
# update-alternatives --config java
There are 2 programs which provide 'java'.
Selection Command
-----------------------------------------------
*+ 1 /usr/lib/jvm/jre-1.7.0-openjdk.x86_64/bin/java
2 /usr/lib/jvm/jre-1.6.0-openjdk.x86_64/bin/java
安装Oracle JDK 1.7:
# rpm -ivh /mnt/hgfs/pub/jdk-7u45-linux-x64.rpm
update-alternatives添加Oracle JDK 1.7:
# update-alternatives --install /usr/bin/java java /usr/java/jdk1.7.0_45/bin/java 1
更改缺省JDK版本:
# update-alternatives --config java
There are 3 programs which provide 'java'.
Selection Command
-----------------------------------------------
*+ 1 /usr/lib/jvm/jre-1.7.0-openjdk.x86_64/bin/java
2 /usr/lib/jvm/jre-1.6.0-openjdk.x86_64/bin/java
3 /usr/java/jdk1.7.0_45/bin/java
Enter to keep the current selection[+], or type selection number: 3
# java -version
java version "1.7.0_45"
Java(TM) SE Runtime Environment (build 1.7.0_45-b18)
Java HotSpot(TM) 64-Bit Server VM (build 24.45-b08, mixed mode)