CentOS卸載系統內建的OpenJDK並安裝Sun的JDK的方法

來源:互聯網
上載者:User

查看目前系統的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]# 

 ================================================

 

 至此,整個安裝過程完畢。

 

 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.