CentOS 5.5系統上已經有安裝OpenJDK可用,如果有需要使用其他特別指定的JDK版本,例如SUN的JDK,就需要額外下載安裝。因為大部份的程式只要把 JAVA_HOME 設好就可以使用了,下載解壓版是最簡單的方式,作法是去SUN的網站下載JDK檔案後,直接解壓縮在指定的目錄下面就可以了。另一種較完整的安裝方式可以下載RPM檔,然後透過安裝RPM的方式安裝JDK,然後在CentOS上再作設定即可!!
現在紀錄安裝SUN的JRE過程:

 
1. 找出下載的JRE原始檔的檔名與位置
[root@easychen easy]# ll
total 20452
drwxr-xr-x 2 root root     4096 Mar  3 22:58 Download
-rw-rw-r-- 1 easy easy 20888537 Mar  3 23:26 jre-6u24-linux-i586-rpm.bin

2. 安裝JRE的RPM檔
[root@easychen easy]# sh ./jre-6u24-linux-i586-rpm.bin 
Unpacking...
Checksumming...
Extracting...
UnZipSFX 5.50 of 17 February 2002, by Info-ZIP (Zip-Bugs@lists.wku.edu).
  inflating: jre-6u24-linux-i586.rpm  
Preparing...                ########################################### [100%]
   1:jre                    ########################################### [100%]
Unpacking JAR files...
        rt.jar...
        jsse.jar...
        charsets.jar...
        localedata.jar...
        plugin.jar...
        javaws.jar...
        deploy.jar...
 
Done.

3. 查詢已經安裝的JAVA與JRE環境
[root@easychen easy]# rpm -qa | grep java
tzdata-java-2010l-1.el5
java-1.4.2-gcj-compat-1.4.2.0-40jpp.115
java-1.6.0-openjdk-1.6.0.0-1.16.b17.el5
[root@easychen easy]# rpm -qa | grep jre
jre-1.6.0_24-fcs

4. 檢視系統內已經設定好的java環境,得知目前的環境是OpenJDK的1.6.0版
[root@easychen easy]# update-alternatives --config java
There are 2 programs which provide 'java'.
  Selection    Command
-----------------------------------------------
*+ 1           /usr/lib/jvm/jre-1.6.0-openjdk/bin/java
   2           /usr/lib/jvm/jre-1.4.2-gcj/bin/java

Enter to keep the current selection[+], or type selection number: 
[root@easychen java]# java -version
java version "1.6.0_17"
OpenJDK Runtime Environment (IcedTea6 1.7.5) (rhel-1.16.b17.el5-i386)
OpenJDK Client VM (build 14.0-b16, mixed mode)


5. 確認目前java執行檔的位置
[root@easychen easy]# which java
/usr/bin/java

6. 檢查新安裝的JRE的版本
[root@easychen /]# cd /usr/java/jre1.6.0_24/bin
[root@easychen bin]# ll
total 788
lrwxrwxrwx 1 root root     10 Mar  3 23:32 ControlPanel -> ./jcontrol
-rwxr-xr-x 1 root root  47308 Feb  3 11:36 java
-rwxr-xr-x 1 root root  16835 Feb  3 11:36 java_vm
-rwxr-xr-x 1 root root  74417 Feb  3 11:36 javaws
-rwxr-xr-x 1 root root   6407 Feb  3 09:34 jcontrol
-rwxr-xr-x 1 root root  47447 Feb  3 11:36 keytool
-rwxr-xr-x 1 root root  47679 Feb  3 11:36 orbd
-rwxr-xr-x 1 root root  47515 Feb  3 11:36 pack200
-rwxr-xr-x 1 root root  47807 Feb  3 11:36 policytool
-rwxr-xr-x 1 root root  47447 Feb  3 11:36 rmid
-rwxr-xr-x 1 root root  47447 Feb  3 11:36 rmiregistry
-rwxr-xr-x 1 root root  47475 Feb  3 11:36 servertool
-rwxr-xr-x 1 root root  47679 Feb  3 11:36 tnameserv
-rwxr-xr-x 1 root root 189274 Feb  3 11:36 unpack200
[root@easychen bin]# ./java -version
java version "1.6.0_24"
Java(TM) SE Runtime Environment (build 1.6.0_24-b07)
Java HotSpot(TM) Client VM (build 19.1-b02, mixed mode, sharing)

7. 新增SUN的JRE環境到系統的JAVA執行環境內
[root@easychen java]# alternatives --install /usr/bin/java java /usr/java/jre1.6.0_24/bin/java 300

8. 檢視目前可使用的JAVA環境
[root@easychen java]# alternatives --config java
There are 3 programs which provide 'java'.
  Selection    Command
-----------------------------------------------
*+ 1           /usr/lib/jvm/jre-1.6.0-openjdk/bin/java
   2           /usr/lib/jvm/jre-1.4.2-gcj/bin/java
   3           /usr/java/jre1.6.0_24/bin/java
Enter to keep the current selection[+], or type selection number:

9. 確認原始預設的JAVA環境版本尚未變更
[root@easychen java]# java -version
java version "1.6.0_17"
OpenJDK Runtime Environment (IcedTea6 1.7.5) (rhel-1.16.b17.el5-i386)
OpenJDK Client VM (build 14.0-b16, mixed mode)

10. 替換目前環境使用的JAVA
[root@easychen java]# alternatives --config java
There are 3 programs which provide 'java'.
  Selection    Command
-----------------------------------------------
*+ 1           /usr/lib/jvm/jre-1.6.0-openjdk/bin/java
   2           /usr/lib/jvm/jre-1.4.2-gcj/bin/java
   3           /usr/java/jre1.6.0_24/bin/java
Enter to keep the current selection[+], or type selection number: 3

11. 確認新的JAVA預設版本以變更為新版的JAVA
[root@easychen java]# alternatives --config java
There are 3 programs which provide 'java'.
  Selection    Command
-----------------------------------------------
*  1           /usr/lib/jvm/jre-1.6.0-openjdk/bin/java
   2           /usr/lib/jvm/jre-1.4.2-gcj/bin/java
 + 3           /usr/java/jre1.6.0_24/bin/java

Enter to keep the current selection[+], or type selection number: 

[root@easychen java]# java -version
java version "1.6.0_24"
Java(TM) SE Runtime Environment (build 1.6.0_24-b07)
Java HotSpot(TM) Client VM (build 19.1-b02, mixed mode, sharing)

創作者介紹

簡單

easychen 發表在 痞客邦 留言(0) 人氣()