先前系统上有JDK 6的安装,由于要部署Facebook的Presto做一些测试,需要将其升级到JDK 7,但是在安装的过程中遇到以下的问题:
[root@x01 data2]# rpm -ivh --force --replacepkgs jdk-7u45-linux-x64.rpm Preparing... ########################################### [100%] 1:jdk ########################################### [100%] Unpacking JAR files... rt.jar... Error: Could not open input file: /usr/java/jdk1.7.0_45/jre/lib/rt.pack Error: unpack could not create JAR file: /usr/java/jdk1.7.0_45/jre/lib/rt.jar Please refer to the Troubleshooting section of the Installation Instructions on the download page. jsse.jar... Error: Could not open input file: /usr/java/jdk1.7.0_45/jre/lib/jsse.pack Error: unpack could not create JAR file: /usr/java/jdk1.7.0_45/jre/lib/jsse.jar Please refer to the Troubleshooting section of the Installation Instructions on the download page. charsets.jar... Error: Could not open input file: /usr/java/jdk1.7.0_45/jre/lib/charsets.pack Error: unpack could not create JAR file: /usr/java/jdk1.7.0_45/jre/lib/charsets.jar Please refer to the Troubleshooting section of the Installation Instructions on the download page. tools.jar... Error: Could not open input file: /usr/java/jdk1.7.0_45/lib/tools.pack Error: unpack could not create JAR file: /usr/java/jdk1.7.0_45/lib/tools.jar Please refer to the Troubleshooting section of the Installation Instructions on the download page. localedata.jar... Error: Could not open input file: /usr/java/jdk1.7.0_45/jre/lib/ext/localedata.pack Error: unpack could not create JAR file: /usr/java/jdk1.7.0_45/jre/lib/ext/localedata.jar Please refer to the Troubleshooting section of the Installation Instructions on the download page. jfxrt.jar... Error: Could not open input file: /usr/java/jdk1.7.0_45/jre/lib/jfxrt.pack Error: unpack could not create JAR file: /usr/java/jdk1.7.0_45/jre/lib/jfxrt.jar Please refer to the Troubleshooting section of the Installation Instructions on the download page.
如果在这种情况下,我们查看Java的版本,会报出以下的错误:
[root@x01 data2]# java -version Error occurred during initialization of VM java/lang/NoClassDefFoundError: java/lang/Object
最终的解决办法,是清理掉系统残留的旧版本的相关的安装:
[root@x01 data2]# rpm -qa | grep jdk jdk-1.7.0_45-fcs.x86_64 [root@x01 data2]# rpm -e jdk-1.7.0_45-fcs.x86_64 [root@x01 data2]# rpm -qa | grep jdk [root@x01 data2]# rpm -qa | grep java sun-javadb-core-10.6.2-1.1.i386 sun-javadb-javadoc-10.6.2-1.1.i386 sun-javadb-common-10.6.2-1.1.i386 sun-javadb-client-10.6.2-1.1.i386 sun-javadb-docs-10.6.2-1.1.i386 sun-javadb-demo-10.6.2-1.1.i386 [root@x01 data2]# rpm -e sun-javadb-* error: package sun-javadb-* is not installed [root@x01 data2]# rpm -e sun-javadb-core-10.6.2-1.1.i386 sun-javadb-javadoc-10.6.2-1.1.i386 sun-javadb-common-10.6.2-1.1.i386 sun-javadb-client-10.6.2-1.1.i386 sun-javadb-docs-10.6.2-1.1.i386 sun-javadb-demo-10.6.2-1.1.i386 [root@x01 data2]# rpm -qa | grep java [root@x01 data2]# rpm -qa | grep jre [root@x01 data2]# rpm -qa | grep java [root@x01 data2]# rpm -qa | grep jdk
这样之后,再运行先前的安装程序即可:
[root@x01 data2]# rpm -ivh jdk-7u45-linux-x64.rpm Preparing... ########################################### [100%] 1:jdk ########################################### [100%] Unpacking JAR files... rt.jar... jsse.jar... charsets.jar... tools.jar... localedata.jar... jfxrt.jar... [root@x01 data2]# source /etc/profile [root@x01 data2]# java -version java version "1.7.0_45" Java(TM) SE Runtime Environment (build 1.7.0_45-b18) Java HotSpot(TM) 64-Bit Server VM (build 24.45-b08, mixed mode) [root@x01 data2]#
Done!