redhat6.5 jdk卸载安装配置

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了redhat6.5 jdk卸载安装配置相关的知识,希望对你有一定的参考价值。

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

一.卸载openJDK

[[email protected] ~]# 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)

[[email protected] ~]#  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

[[email protected] ~]#  rpm -qa | grep gcj

[[email protected] ~]# 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)

[[email protected] ~]# 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

[[email protected] usr]# cd

[[email protected] ~]# 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

[[email protected] ~]# cp -r jdk-7u79-linux-x64.rpm /usr/java    

[[email protected] ~]# 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

[[email protected] ~]# cd /usr/java

[[email protected] java]# ls

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

[[email protected] 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...

[[email protected] 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

 

[[email protected] ~]# 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卸载安装配置的主要内容,如果未能解决你的问题,请参考以下文章

Linux redhat6.5中 PHP安装配置

jdk的卸载及安装+环境变量的配置

VMware安装Redhat6.5

redhat6.5部署oracle 11G R2 (参考配置)

如何卸载JDK

Centos 6.5下的OPENJDK卸载和SUN的JDK安装环境变量配置