查看目前系統的jdk: rpm -qa | grep jdk
得到的結果:
[root@dc-01 java]# rpm -qa | grep jdk
java-1.6.0-openjdk-1.6.0.0-1.45.1.11.1.el6.i686
卸載之:
[root@dc-01 java]# yum -y remove java-1.6.0-openjdk-1.6.0.0-1.45.1.11.1.el6.i686
等一段時間就Complete了。
下載Sun的JDK。我下載的是
jdk-6u37-linux-i586-rpm.bin
如果是64位系統的話,要下載:
jdk-6u37-linux-x64-rpm.bin
之類的64位專用的包
到/usr目錄下建立java目錄,將下載的檔案放到/usr/java目錄下
先將這個檔案變為可執行檔(chmod 777) :
[root@dc-01 java]# chmod 777 jdk-6u37-linux-i586-rpm.bin
然後執行這個檔案件進行安裝:
[root@dc-01 java]# ./jdk-6u37-linux-i586-rpm.bin Unpacking...Checksumming...Extracting...UnZipSFX 5.50 of 17 February 2002, by Info-ZIP (Zip-Bugs@lists.wku.edu). inflating: jdk-6u37-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 JavaDBPreparing... ########################################### [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 documentationProduct and system data will be collected. If your configurationsupports a browser, the JDK Product Registration form willbe presented. If you do not register, none of this informationwill be saved. You may also register your JDK later byopening the register.html file (located in the JDK installationdirectory) 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 .
至此安裝結束。
接下來配置JDK:
vi /etc/profile開啟profile檔案,在profile檔案的末尾加上:
JAVA_HOME=/usr/java/jdk1.6.0_37PATH=$JAVA_HOME/bin:$PATHCLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jarexport JAVA_HOMEexport PATHexport CLASSPATH
儲存並關閉profile檔案,執行source /etc/profile命令讓修改生效。
運行下java-version 看一下java版本 :
[root@dc-01 java]# java -version
java version "1.6.0_37"Java(TM) SE Runtime Environment (build 1.6.0_37-b06)Java HotSpot(TM) Client VM (build 20.12-b01, mixed mode, sharing)[root@dc-01 java]#
================================================
至此,整個安裝過程完畢。