某机器安装了非常旧版本的红帽:
[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后卸载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)