1. 程式人生 > >Rhel6下JDK1.6.0的配置

Rhel6下JDK1.6.0的配置

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)