`

linux 下JDK的卸载与安装

阅读更多
###################################################JDK卸载
[root@192.xxx.xxx.xxx boot]# java -version //检查JDK版本命令
java version "1.4.2"
gij (GNU libgcj) version 4.1.2 20080704 (Red Hat 4.1.2-46)
[root@192.xxx.xxx.xxx boot]# rpm -qa | grep jdk  //检查命令1
[root@192.xxx.xxx.xxx boot]# rpm -qa | grep gcj  //检查命令2
java-1.4.2-gcj-compat-1.4.2.0-40jpp.115
libgcj-4.1.2-46.el5
java-1.4.2-gcj-compat-src-1.4.2.0-40jpp.115
libgcj-devel-4.1.2-46.el5
java-1.4.2-gcj-compat-devel-1.4.2.0-40jpp.115
libgcj-src-4.1.2-46.el5
[root@192.xxx.xxx.xxx boot]# yum -y remove java-1.4.2-gcj-compat-1.4.2.0-40jpp.115 Loaded plugins: rhnplugin, security   //卸载命令
This system is not registered with RHN.
RHN support will be disabled.
Setting up Remove Process
Resolving Dependencies
--> Running transaction check
---> Package java-1.4.2-gcj-compat.i386 0:1.4.2.0-40jpp.115 set to be erased
--> Processing Dependency: java-gcj-compat for package: jakarta-commons-codec
--> Processing Dependency: java-gcj-compat for package: jakarta-commons-codec
--> Processing Dependency: java-gcj-compat for package: antlr
--> Processing Dependency: java-gcj-compat for package: antlr
--> Processing Dependency: java-gcj-compat for package: junit
--> Processing Dependency: java-gcj-compat for package: junit
--> Processing Dependency: java-gcj-compat for package: jakarta-commons-logging
--> Processing Dependency: java-gcj-compat for package: jakarta-commons-logging
--> Processing Dependency: java-gcj-compat >= 1.0.31 for package: tomcat5-jsp-2.0-api
--> Processing Dependency: java-gcj-compat >= 1.0.31 for package: tomcat5-jsp-2.0-api
--> Processing Dependency: java-gcj-compat >= 1.0.64 for package: gjdoc
--> Processing Dependency: java-gcj-compat >= 1.0.64 for package: gjdoc
--> Processing Dependency: java-gcj-compat for package: jakarta-commons-httpclient
--> Processing Dependency: java-gcj-compat for package: jakarta-commons-httpclient
--> Processing Dependency: java-gcj-compat >= 1.0.31 for package: tomcat5-servlet-2.4-api
--> Processing Dependency: java-gcj-compat >= 1.0.31 for package: tomcat5-servlet-2.4-api
--> Processing Dependency: java-gcj-compat for package: bsf
--> Processing Dependency: java-gcj-compat for package: bsf
--> Processing Dependency: java-gcj-compat for package: xalan-j2
--> Processing Dependency: java-gcj-compat for package: xalan-j2
--> Processing Dependency: java-gcj-compat for package: xmlrpc
--> Processing Dependency: java-gcj-compat for package: xmlrpc
--> Processing Dependency: java-gcj-compat for package: bsh
--> Processing Dependency: java-gcj-compat for package: bsh
--> Processing Dependency: jaxp_parser_impl for package: xalan-j2
--> Processing Dependency: java-1.4.2-gcj-compat = 1.4.2.0-40jpp.115 for package: java-1.4.2-gcj-compat-src
--> Processing Dependency: java-1.4.2-gcj-compat = 1.4.2.0-40jpp.115 for package: java-1.4.2-gcj-compat-devel
--> Running transaction check
---> Package antlr.i386 0:2.7.6-4jpp.2 set to be erased
---> Package bsf.i386 0:2.3.0-11jpp.1 set to be erased
---> Package bsh.i386 0:1.3.0-9jpp.1 set to be erased
---> Package gjdoc.i386 0:0.7.7-12.el5 set to be erased
---> Package jakarta-commons-codec.i386 0:1.3-7jpp.2 set to be erased
---> Package jakarta-commons-httpclient.i386 1:3.0-7jpp.1 set to be erased
---> Package jakarta-commons-logging.i386 0:1.0.4-6jpp.1 set to be erased
---> Package java-1.4.2-gcj-compat-devel.i386 0:1.4.2.0-40jpp.115 set to be erased
---> Package java-1.4.2-gcj-compat-src.i386 0:1.4.2.0-40jpp.115 set to be erased
---> Package junit.i386 0:3.8.2-3jpp.1 set to be erased
---> Package tomcat5-jsp-2.0-api.i386 0:5.5.23-0jpp.7.el5_3.2 set to be erased
---> Package tomcat5-servlet-2.4-api.i386 0:5.5.23-0jpp.7.el5_3.2 set to be erased
---> Package xalan-j2.i386 0:2.7.0-6jpp.1 set to be erased
---> Package xmlrpc.i386 0:2.0.1-3jpp.1 set to be erased
--> Processing Dependency: /usr/bin/rebuild-gcj-db for package: eclipse-ecj
--> Processing Dependency: /usr/bin/rebuild-gcj-db for package: eclipse-ecj
--> Restarting Dependency Resolution with new changes.
--> Running transaction check
---> Package eclipse-ecj.i386 1:3.2.1-19.el5 set to be erased
--> Finished Dependency Resolution

Dependencies Resolved

===============================================================================================
Package                          Arch      Version                       Repository      Size
===============================================================================================
Removing:
java-1.4.2-gcj-compat            i386      1.4.2.0-40jpp.115             installed       441
Removing for dependencies:
antlr                            i386      2.7.6-4jpp.2                  installed      2.5 M
bsf                              i386      2.3.0-11jpp.1                 installed      812 k
bsh                              i386      1.3.0-9jpp.1                  installed      1.2 M
eclipse-ecj                      i386      1:3.2.1-19.el5                installed       18 M
gjdoc                            i386      0.7.7-12.el5                  installed      1.7 M
jakarta-commons-codec            i386      1.3-7jpp.2                    installed      207 k
jakarta-commons-httpclient       i386      1:3.0-7jpp.1                  installed      1.3 M
jakarta-commons-logging          i386      1.0.4-6jpp.1                  installed      233 k
java-1.4.2-gcj-compat-devel      i386      1.4.2.0-40jpp.115             installed       81 k
java-1.4.2-gcj-compat-src        i386      1.4.2.0-40jpp.115             installed       0.0
junit                            i386      3.8.2-3jpp.1                  installed      602 k
tomcat5-jsp-2.0-api              i386      5.5.23-0jpp.7.el5_3.2         installed      163 k
tomcat5-servlet-2.4-api          i386      5.5.23-0jpp.7.el5_3.2         installed      250 k
xalan-j2                         i386      2.7.0-6jpp.1                  installed      5.1 M
xmlrpc                           i386      2.0.1-3jpp.1                  installed      864 k

Transaction Summary
===============================================================================================
Install      0 Package(s)        
Update       0 Package(s)        
Remove      16 Package(s)        

Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
  Erasing        : java-1.4.2-gcj-compat-devel                                            1/16
  Erasing        : bsf                                                                    2/16
  Erasing        : antlr                                                                  3/16
  Erasing        : tomcat5-servlet-2.4-api                                                4/16
  Erasing        : jakarta-commons-codec                                                  5/16
  Erasing        : java-1.4.2-gcj-compat-src                                              6/16
  Erasing        : jakarta-commons-logging                                                7/16
  Erasing        : junit                                                                  8/16
  Erasing        : tomcat5-jsp-2.0-api                                                    9/16
  Erasing        : xmlrpc                                                                10/16
  Erasing        : java-1.4.2-gcj-compat                                                 11/16
  Erasing        : xalan-j2                                                              12/16
  Erasing        : jakarta-commons-httpclient                                            13/16
  Erasing        : bsh                                                                   14/16
  Erasing        : gjdoc                                                                 15/16
  Erasing        : eclipse-ecj                                                           16/16

Removed:
  java-1.4.2-gcj-compat.i386 0:1.4.2.0-40jpp.115                                              

Dependency Removed:
  antlr.i386 0:2.7.6-4jpp.2                                                                   
  bsf.i386 0:2.3.0-11jpp.1                                                                    
  bsh.i386 0:1.3.0-9jpp.1                                                                     
  eclipse-ecj.i386 1:3.2.1-19.el5                                                             
  gjdoc.i386 0:0.7.7-12.el5                                                                   
  jakarta-commons-codec.i386 0:1.3-7jpp.2                                                     
  jakarta-commons-httpclient.i386 1:3.0-7jpp.1                                                
  jakarta-commons-logging.i386 0:1.0.4-6jpp.1                                                 
  java-1.4.2-gcj-compat-devel.i386 0:1.4.2.0-40jpp.115                                        
  java-1.4.2-gcj-compat-src.i386 0:1.4.2.0-40jpp.115                                          
  junit.i386 0:3.8.2-3jpp.1                                                                   
  tomcat5-jsp-2.0-api.i386 0:5.5.23-0jpp.7.el5_3.2                                            
  tomcat5-servlet-2.4-api.i386 0:5.5.23-0jpp.7.el5_3.2                                        
  xalan-j2.i386 0:2.7.0-6jpp.1                                                                
  xmlrpc.i386 0:2.0.1-3jpp.1                                                                  

Complete!
[root@192.xxx.xxx.xxx boot]# java -version                      //再次检查JDK版本,卸载成功
-bash: /usr/bin/java: 没有那个文件或目录


###################################################JDK安装
安装文件:用的安装包是jdk-6u22-linux-i586.bin,没有使用Red Hat平台通用的rpm包。
首先,通过ftp将jdk-6u22-linux-i586.bin上传到/home/software下。
然后,要给jdk-6u11-linux-i586.bin分配权限,这里要给它可执行的权限,输入:chmod +x jdk-6u11-linux-i586.bin,这里参数x即使执行权限。
[root@192.xxx.xxx.xxx /]# cd home/software              //进入安装包所在的目录
[root@192.xxx.xxx.xxx software]# ls
jdk-6u22-linux-i586.bin
[root@192.xxx.xxx.xxx software]#chmod +x jdk-6u22-linux-i586.bin          //赋予可执行的权限
[root@192.xxx.xxx.xxx software]#./jdk-6u22-linux-i586.bin                 //开始解包
.........................省略
Creating jdk1.6.0_22/jre/lib/deploy.jar

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 Sun products, services and training
* Access to early releases and documentation

Product and system data will be collected. If your configuration
supports a browser, the Sun Product Registration form for
the JDK 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.
[root@192.xxx.xxx.xxx software]# ls                                      //查看结包后的目录
jdk1.6.0_22  jdk-6u22-linux-i586.bin
[root@192.xxx.xxx.xxx software]# cd jdk1.6.0_22                          //进入解压包
[root@192.xxx.xxx.xxx jdk1.6.0_22]# ls                                   //查看解压包内的内容
bin        include  README.html        register_ja.html     THIRDPARTYLICENSEREADME.txt
COPYRIGHT  jre      README_ja.html     register_zh_CN.html
db         lib      README_zh_CN.html  sample
demo       man      register.html      src.zip
[root@192.xxx.xxx.xxx software]# mv jdk1.6.0_22 /usr/local               //通常将jdk1.6.0_22放在/usr/local目录下,所以先执行“移动”
[root@192.xxx.xxx.xxx software]# cd /usr/local                           //进入/usr/local目录     
[root@192.xxx.xxx.xxx local]# ls                                         //查看目录内容
bin  etc  games  include  jdk1.6.0_22  lib  libexec  sbin  share  src


###################################################JDK设置环境变量
设置环境变量有两种方法:
一是通过export设置临时生效,重启后设置会丢失。
二是将设置写入/etc/profile文件中,可以一直生效。所以我们采用此方法。
[root@192.xxx.xxx.xxx /]# vi /etc/profile              //打开/etc/profile文件

[root@192.xxx.xxx.xxx /]# vi /etc/profile

# /etc/profile

# System wide environment and startup programs, for login setup
# Functions and aliases go in /etc/bashrc

pathmunge () {
        if ! echo $PATH | /bin/egrep -q "(^|:)$1($|:)" ; then
           if [ "$2" = "after" ] ; then
              PATH=$PATH:$1
           else
              PATH=$1:$PATH
           fi
        fi
}

# ksh workaround
if [ -z "$EUID" -a -x /usr/bin/id ]; then
        EUID=`id -u`
        UID=`id -ru`
fi

# Path manipulation
if [ "$EUID" = "0" ]; then
        pathmunge /sbin
        pathmunge /usr/sbin
        pathmunge /usr/local/sbin
fi

# No core files by default
ulimit -S -c 0 > /dev/null 2>&1

if [ -x /usr/bin/id ]; then
        USER="`id -un`"
        LOGNAME=$USER
        MAIL="/var/spool/mail/$USER"
fi

HOSTNAME=`/bin/hostname`
HISTSIZE=1000

if [ -z "$INPUTRC" -a ! -f "$HOME/.inputrc" ]; then
    INPUTRC=/etc/inputrc
fi

#JDK环境变量设置
export JAVA_HOME=/usr/local/jdk1.6.0_22
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=.:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/rt.jar                     
pathmunge /usr/local/jdk1.6.0_22/bin:/usr/local/jdk1.6.0_22/jre/bin
export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE INPUTRC                    

for i in /etc/profile.d/*.sh ; do
    if [ -r "$i" ]; then
        if [ "$PS1" ]; then
                  . $i
        else
            . $i >/dev/null 2>&1
        fi
    fi
done

unset i
unset pathmunge
"/etc/profile" 58L, 1029C

[root@192.xxx.xxx.xxx /]# source /etc/profile                                       //让配置生效
[root@192.xxx.xxx.xxx /]# java -version                                             //检查JDK版本(新)
java version "1.6.0_22"
Java(TM) SE Runtime Environment (build 1.6.0_22-b04)
Java HotSpot(TM) Client VM (build 17.1-b03, mixed mode, sharing)
分享到:
评论

相关推荐

    Linux下如何安装和卸载JDK

    ### Linux下如何安装和卸载JDK 在Linux系统中安装和卸载Java Development Kit (JDK) 是一项常见的操作任务。本文将详细介绍两种主要的方法:通过`yum`包管理器进行安装与卸载,以及利用`rpm`包管理器进行相同的操作...

    Linux JDK卸载与安装

    首先,我们需要了解Linux下JDK通常的安装路径。在大多数Linux发行版中,JDK可能被安装在 `/usr/lib/jvm` 目录下。你可以通过执行 `ls /usr/lib/jvm` 来查看已安装的JDK版本。另外,还可以通过 `java -version` 命令...

    Linux下安装与卸载jdk

    本文将详细讲解如何在Linux环境下安装与卸载JDK,以满足开发和管理Java项目的需求。 首先,我们来了解安装JDK的过程。在Linux上安装JDK主要有两种方法:使用官方提供的二进制包或通过包管理器(如apt-get for ...

    linux下查看已经安装的jdk 并卸载jdk

    ### Linux下查看已安装的JDK并卸载的方法 #### 一、查看JDK的安装路径 在Linux环境中,为了确保...通过以上步骤,你可以有效地在Linux环境下管理JDK的安装与卸载过程。这对于维护一个干净、高效的开发环境非常重要。

    linux安装卸载jdk

    ### Linux下安装与卸载JDK的详细指南 #### 一、配置信息 在开始之前,我们需要了解关于系统的配置信息以及准备使用的JDK版本。 **1.1 系统配置信息** - **操作系统**: Red Hat Enterprise Linux (RHEL) 5 - **...

    Linux下JDK+Tomcat安装配置

    Linux下JDK+Tomcat安装配置 在本文档中,我们将详细介绍如何在CentOS系统上安装和配置JDK和Tomcat环境。以下是整个安装和配置过程的步骤。 一、下载所需文件 在开始安装之前,需要下载两个必要的文件:jdk-7u25-...

    Linux-Linux下安装卸载JDK

    本教程将详细介绍如何在Linux环境下安装和卸载JDK。 **一、安装JDK** 1. **选择版本**: 首先,你需要确定要安装的JDK版本。Oracle和AdoptOpenJDK等供应商提供不同版本的JDK,包括长期支持(LTS)版本,例如Java 8和...

    linux安装jdk 首先先 卸载 linux自带的jdk 然后在安装你想要的jdk版本

    linux 里面安装jdk 步骤非常的详细 不会出错,用完记得谢我

    linux下查看已经安装的jdk 并卸载jdk的方法(推荐)

    一、查看Jdk的安装路径: whereis java which java (java执行路径) echo $JAVA_HOME echo $PATH 备注:如果是windows中,可以使用: set java_home:查看JDK安装路径 java -version:查看JDK版本 二、卸载旧版本的...

    Linux 下安装与卸载JDK1

    Linux 下安装与卸载 JDK Linux 是一个流行的开源操作系统,广泛应用于服务器、个人电脑和嵌入式系统等领域。Java 是一种流行的编程语言,它可以在多种平台上运行,包括 Linux。为了在 Linux 上使用 Java,我们需要...

    linux安装和卸载jdk-6u21

    ### Linux安装和卸载JDK-6u21 #### 安装JDK-6u21 在Linux系统上安装JDK-6u21是进行Java开发的基础步骤之一。下面详细介绍整个安装过程。 ##### 步骤1:下载JDK安装包 首先,需要从Oracle官方网站或可信源下载...

    linux jdk+tomcat安装

    #### 一、Linux JDK 安装与配置 **1. 解压安装 JDK** - **准备 JDK 安装文件:** - 首先确保您已经下载了适合您 Linux 系统版本的 JDK 安装包。例如,本文档中的示例使用的是 `jdk-6u14-linux-i586.bin` 文件。 ...

    suse系统下安装JDK

    "suse系统下安装JDK" SUSE Linux Enterprise 10 64-bit系统中安装JDK(Java Development Kit)的详细步骤。 一、卸载自带的JDK 在安装JDK之前,需要检查是否已经安装了自带的JDK 1.4。可以使用命令`#rpm -qa | ...

    Linux安装JDK1.6

    ### Linux安装JDK1.6 #### 知识点概览 - **下载与准备**:获取JDK1.6的安装包,并将其放置在...通过以上步骤,可以顺利完成Linux环境下JDK1.6的安装配置工作。这些步骤不仅适用于JDK1.6,也适用于其他版本的JDK安装。

    Linux更换JDK+weblogic更换JDK

    ### Linux系统更换JDK与WebLogic服务器更换JDK详解 #### 一、概述 在Linux环境中,更换JDK(Java Development Kit)对于确保应用程序能够稳定运行至关重要。此外,如果使用了Oracle WebLogic Server作为应用服务器...

    linux下安装JDK

    "Linux下安装JDK" 在Linux系统中安装JDK是一个非常重要的步骤,这对于Java开发者和Linux用户来说都是必备的技能。在本文中,我们将详细讲解如何在Linux系统中安装JDK。 第一步:查看Linux自带的JDK是否已安装 在...

    linux下jdk的tar.gz文件安装

    linux下jdk的tar.gz文件安装。从linux下的openjdk卸载到jdk的tar.gz文件下载到jdk安装完成,每一步都有详实记录

    linux安装jdk1.8(实测没问题)

    ### Linux下安装JDK 1.8 的详细步骤与注意事项 #### 一、JDK与OpenJDK的区别 在开始介绍如何在Linux环境下安装JDK 1.8之前,我们首先了解一下JDK与OpenJDK之间的区别。这些差异对于用户来说很重要,尤其是在选择...

    linux 上安装jdk 1.6

    ### 知识点一:理解Linux下JDK的安装流程 #### 1. 检查已安装的Java组件 在开始安装新的JDK版本之前,检查系统上是否已经存在其他Java组件是非常重要的。这可以通过使用`rpm -qa | grep gcj`命令来完成,它将列出...

Global site tag (gtag.js) - Google Analytics