RedHat6.1(64bit)安装JDK

时间:2023-03-08 20:36:33
RedHat6.1(64bit)安装JDK

今天在服务器上装JDK1.5,费了不少力气,记录下来以供参考

服务器安装的操作系统为Red Hat 6.1(x86)

[123@123 bin]$ cat /etc/redhat-release
Red Hat Enterprise Linux Workstation release 6.1 (Santiago)
[123@123 ~]$ uname -op
x86_64 GNU/Linux

由于项目使用JDK1.5编译,故在安装JDK时首先选则的jdk-1_5_0_22-linux-i586.bin:

Do you agree to the above license terms? [yes or no]
yes
Unpacking...
Checksumming...
0
0
Extracting...
./jdk-1_5_0_15-linux-i586.bin: ./install.sfx.2991: /lib/ld-linux.so.2: bad ELF interpreter: No such file or directory
mkdir: cannot create directory `jdk1.5.0_15/jre': No such file or directory
mkdir: cannot create directory `jdk1.5.0_15/jre/.systemPrefs': No such file or directory
touch: cannot touch `jdk1.5.0_15/jre/.systemPrefs/.system.lock': No such file or directory
chmod: cannot access `jdk1.5.0_15/jre/.systemPrefs/.system.lock': No such file or directory
touch: cannot touch `jdk1.5.0_15/jre/.systemPrefs/.systemRootModFile': No such file or directory
chmod: cannot access `jdk1.5.0_15/jre/.systemPrefs/.systemRootModFile': No such file or directory
./jdk-1_5_0_15-linux-i586.bin: line 680: cd: jdk1.5.0_15: No such file or directory Done.

搜索了一下/lib/ld-linux.so.2: bad ELF interpreter这个错误,很多地方提示安装glib(一个跨平台的、用c语言编写的库)即可解决,不过我没尝试过

RedHat6.1(64bit)安装JDK

剩余的选择不多,既然32位JDK1.5无法安装,尝试下64位JDK1.5

选择jdk-1_5_0_22-linux-amd64.bin再次尝试,安装成功,但是在运行时会提示找不到java.lang.Object

[123@123 bin]$ ./java -version
Error occurred during initialization of VM
java/lang/NoClassDefFoundError: java/lang/Object

在jdk1.5.0_11/jre/lib目录下竟然没有rt.jar!

查了下有人自己上传rt.jar解决了这个问题,手头上没有64位的rt.jar,用32位的尝试了下,果然是不行的

[123@123 bin]$ ./java -version
Error occurred during initialization of VM
java.lang.UnsatisfiedLinkError: set

其实这是一个很明显的错误,安装包上明确写着amd64,即这是专门为amd64架构的处理器使用的

[123@123 ~]$ cat /proc/cpuinfo|grep 'model name'
model name      : Intel(R) Xeon(R) CPU           E5620  @ 2.40GHz

服务器上的英特尔Xeon E5620处理器使用的是Intel64(EM64T)架构

万般无奈下,考虑到JDK版本向下兼容,最终选择了1.6版本的JDK

RedHat6.1(64bit)安装JDK

比起JDK1.5,JDK1.6安装包的名称更清晰易懂(直接使用x64,不再区分amd64与intel64),选择安装jdk-6u45-linux-x64.bin,没有问题:

[123@123 web]$ ./jdk1.6.0_45/bin/java -version
java version "1.6.0_45"
Java(TM) SE Runtime Environment (build 1.6.0_45-b06)
Java HotSpot(TM) 64-Bit Server VM (build 20.45-b01, mixed mode)

当然如果选择jdk-6u45-linux-i586.bin应该也是没有问题的

特别需要注意的是Red Hat 6.1(x86)中自带的JDK为OpenJDK而非Java(TM)

[123@123 ~]$ java -version
java version "1.6.0_20"
OpenJDK Runtime Environment (IcedTea6 1.9.7) (rhel-1.39.1.9.7.el6-x86_64)
OpenJDK 64-Bit Server VM (build 19.0-b09, mixed mode)

这两个JDK还是有一定差异的,在Java(TM)环境下编译并能正常运行的程序在OpenJDK环境下不一定能正常运行