redhat6.5 jdk卸载安装配置

Redhat Linux 6.5 安装JDK时,可能系统中已安装了老版本的JDK,这时要先卸载老版的,之后再安装新版本。

一.卸载openJDK

[root@master ~]# java -version 

java version "1.7.0_45"

OpenJDK Runtime Environment (rhel-2.4.3.3.el6-x86_64 u45-b15)

OpenJDK 64-Bit Server VM (build 24.45-b08, mixed mode)

[root@master ~]#  rpm -qa | grep jdk

java-1.7.0-openjdk-1.7.0.45-2.4.3.3.el6.x86_64

java-1.6.0-openjdk-1.6.0.0-1.66.1.13.0.el6.x86_64

[root@master ~]#  rpm -qa | grep gcj

[root@master ~]# java -version     

java version "1.7.0_45"

OpenJDK Runtime Environment (rhel-2.4.3.3.el6-x86_64 u45-b15)

OpenJDK 64-Bit Server VM (build 24.45-b08, mixed mode)

[root@master ~]# yum -y remove java-1.7.0-openjdk-1.7.0.45-2.4.3.3.el6.x86_64                                       Loaded plugins: product-id, refresh-packagekit, security, subscription-manager

This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.

Setting up Remove Process

Resolving Dependencies

--> Running transaction check

---> Package java-1.7.0-openjdk.x86_64 1:1.7.0.45-2.4.3.3.el6 will be erased

--> Finished Dependency Resolution

 

Dependencies Resolved

 

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

 Package             Arch    Version                 Repository                                                Size

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

Removing:

 java-1.7.0-openjdk  x86_64  1:1.7.0.45-2.4.3.3.el6  @anaconda-RedHatEnterpriseLinux-201311111358.x86_64/6.5   90 M

 

Transaction Summary

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

Remove        1 Package(s)

 

Installed size: 90 M

Downloading Packages:

Running rpm_check_debug

Running Transaction Test

Transaction Test Succeeded

Running Transaction

  Erasing    : 1:java-1.7.0-openjdk-1.7.0.45-2.4.3.3.el6.x86_64                                                 1/1

  Verifying  : 1:java-1.7.0-openjdk-1.7.0.45-2.4.3.3.el6.x86_64                                                 1/1

 

Removed:

  java-1.7.0-openjdk.x86_64 1:1.7.0.45-2.4.3.3.el6                                                                 

 

Complete!

二.安装oracle JDK

创建安装目录,在/usr/java下建立安装路径,并将文件考到该路径下: 
mkdir /usr/java

[root@master usr]# cd

[root@master ~]# ls

anaconda-ks.cfg  Downloads           jdk-7u79-linux-x64.rpm     Pictures                            Templates

Desktop          install.log         jdk-7u79-linux-x64.tar.gz  Public                              Videos

Documents        install.log.syslog  Music                      rabbitmq-server-3.6.0-1.noarch.rpm

[root@master ~]# cp -r jdk-7u79-linux-x64.rpm /usr/java    

[root@master ~]# ls

anaconda-ks.cfg  Downloads           jdk-7u79-linux-x64.rpm     Pictures                            Templates

Desktop          install.log         jdk-7u79-linux-x64.tar.gz  Public                              Videos

Documents        install.log.syslog  Music                      rabbitmq-server-3.6.0-1.noarch.rpm

[root@master ~]# cd /usr/java

[root@master java]# ls

jdk-7u79-linux-x64.rpm  jdk-8u20-linux-x64.rpm

[root@master java]#

 

 

将jdk-7u79-linux-x64.rpm上传到/usr/java下。然后,要给jdk-7u79-linux-x64.rpm

分配权限,具体的这里要给它可执行的权限,输入:chmod +x jdk-7u79-linux-x64.rpm

开始执行安装命令: rpm -ivh jdk-7u79-linux-x64.rpm

Preparing...                ########################################### [100%]

   1:jdk                    ########################################### [100%]

Unpacking JAR files...

        rt.jar...

        jsse.jar...

        charsets.jar...

        tools.jar...

        localedata.jar...

        jfxrt.jar...

[root@master java]#

 

 

2.设置环境变量。

 

#vi /etc/profile

 

在最后面加入 输入 i

JAVA_HOME=/usr/java/jdk1.7.0_79

PATH=$JAVA_HOME/bin:$PATH

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

export JAVA_HOME

export PATH

export CLASSPATH

 

保存退出:

按Esc :wq回车即可,重启登录生效

四.验证环境变量配置成功

 

输入:which java 得到JAVA的执行路径,说明配置成功

/usr/java/jdk1.7.0_79/bin/java

输入:echo $JAVA_HOME

/usr/java/jdk1.7.0_79

 

[root@master ~]# echo $PATH

/usr/java/jdk1.7.0_79/bin:/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin

你可能感兴趣的:(redhat6.5 jdk卸载安装配置)