Red Hat Linux卸载旧版本的JDK安装新版本的JDK并附yum安装

某机器安装了非常旧版本的红帽:

[root@localhost ~]# uname -a
Linux localhost.localdomain 2.6.9-5.EL #1 Wed Jan 5 19:22:18 EST 2005 i686 i686 i386 GNU/Linux
[root@localhost ~]# file /sbin/init
/sbin/init: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.2.5, dynamically linked (uses shared libs), stripped

 

JDK是1.4.2。

[root@localhost ~]# rpm -qa | grep gcj
libgcj-devel-3.4.3-9.EL4
libgcj-3.4.3-9.EL4
java-1.4.2-gcj-compat-1.4.2.0-26jpp

先使用yum卸载。结果发现连yum都没。。。

[root@localhost ~]# yum yum -y remove java-1.4.2-gcj-compat-1.4.2.0-26jpp

bash: java: command not found

 

。。。先找yum。根据网上的指点:

yum下载安装 写道
1.如果没有安装yum,就先安装yum
[root@st ~]#wget http://www.parallels.com.cn/downloads/Prima/Tools/yum_forAS4.tar.gz 下载yum软件
[root@st ~]# tar zxvf yum_forAS4.tar.gz
yum_forAS4/
yum_forAS4/CentOS-Base.repo
yum_forAS4/python-elementtree-1.2.6-7.el4.rf.i386.rpm
yum_forAS4/python-urlgrabber-2.9.7-1.2.el4.rf.noarch.rpm
yum_forAS4/yum-2.4.2-0.4.el4.rf.noarch.rpm
yum_forAS4/sqlite-2.8.16-1.2.el4.rf.i386.rpm
yum_forAS4/python-sqlite-1.0.1-1.2.el4.rf.i386.rpm
[root@st ~]# cd yum_forAS4
[root@st yum_forAS4]# ls
CentOS-Base.repo
python-elementtree-1.2.6-7.el4.rf.i386.rpm
python-sqlite-1.0.1-1.2.el4.rf.i386.rpm
python-urlgrabber-2.9.7-1.2.el4.rf.noarch.rpm
sqlite-2.8.16-1.2.el4.rf.i386.rpm
yum-2.4.2-0.4.el4.rf.noarch.rpm
[root@st yum_forAS4]# rpm -ivh *.rpm
warning: python-elementtree-1.2.6-7.el4.rf.i386.rpm: V3 DSA signature: NOKEY,
key ID 6b8d79e6
Preparing... ########################################### [100%]
1:sqlite ########################################### [ 20%]
2:python-sqlite ########################################### [ 40%]
3:python-urlgrabber ########################################### [ 60%]
4:python-elementtree ########################################### [ 80%]
5:yum ########################################### [100%]
[root@st yum_forAS4]# cp CentOS-Base.repo /etc/yum.repos.d/
执行如下命令导入GPG Key
[root@st yum_forAS4]# rpm --import http://mirror.centos.org/centos/RPM-GPG-KEY-
CentOS-4

 
安装yum后卸载JDK1.4:

[root@localhost yum_forAS4]# yum -y remove java-1.4.2-gcj-compat-1.4.2.0-26jpp
Setting up Remove Process
Resolving Dependencies
--> Populating transaction set with selected packages. Please wait.
---> Package java-1.4.2-gcj-compat.noarch 0:1.4.2.0-26jpp set to be erased
--> Running transaction check

Dependencies Resolved

=============================================================================
 Package                 Arch       Version          Repository        Size
=============================================================================
Removing:
 java-1.4.2-gcj-compat   noarch     1.4.2.0-26jpp    installed         2.2 k

Transaction Summary
=============================================================================
Install      0 Package(s)
Update       0 Package(s)
Remove       1 Package(s)
Total download size: 0
Downloading Packages:
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
  Removing  : java-1.4.2-gcj-compat        ######################### [1/1]

Removed: java-1.4.2-gcj-compat.noarch 0:1.4.2.0-26jpp
Complete!

 

这个时候,卸载成功:

[root@localhost yum_forAS4]# java -version
bash: java: command not found

 

下载到新版本的JDK jdk-6u22-linux-i586-rpm.bin

首先分配权限

[root@localhost java]# chmod 755 jdk-6u22-linux-i586-rpm.bin

然后执行安装

[root@localhost java]# ./jdk-6u22-linux-i586-rpm.bin

最后设置path与classpath
[root@localhost java]# export JAVA_HOME=/usr/java/jdk1.6.0_22
[root@localhost java]# export path=$path:$JAVA_HOME/bin;
[root@localhost java]# export path=$path:$JAVA_HOME/jre/bin
[root@localhost java]# export classpath=.:/usr/java/jdk1.6.0_22/lib:/usr/java/jdk1.6.0_22/jre/lib:$CLASSPATH

执行

[root@localhost java]# java -version
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)

你可能感兴趣的:(java,jdk,linux,python,centos)