CentOS卸载系统自带的OpenJDK并安装Sun的JDK的方法

2017-06-08 10:42:18来源:http://ydppcdiy.blog.51cto.com/303317/1933075作者:ydppcdiy人点击


查看目前系统的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 JavaDB

Preparing...########################################### [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 documentation

Product and system data will be collected. If your configuration

supports a browser, the JDK Product Registration form will

be presented. If you do not register, none of this information

will be saved. You may also register your JDK later by

opening the register.html file (located in the JDK installation

directory) 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_37

PATH=$JAVA_HOME/bin:$PATH

CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

export JAVA_HOME

export PATH

export 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]#

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

至此,整个安装过程完毕。


微信扫一扫

第七城市微信公众平台