JRE 1.7 - java 版本 - 返回:java/lang/NoClassDefFoundError:java/lang/Object [英] JRE 1.7 - java version - returns: java/lang/NoClassDefFoundError: java/lang/Object
问题描述
当运行任何 java 应用程序时,或者只是java",jvm 会失败:
When running any java application, or just 'java', the jvm fails:
VM 初始化时出错
java/lang/NoClassDefFoundError: java/lang/Object
Error occurred during initialization of VM
java/lang/NoClassDefFoundError: java/lang/Object
这是错误答案的列表:
正确的 Java 主目录(包括/bin 目录)位于全局 PATH 中
The correct Java home directory, including the /bin directory, is on the global PATH
JAVA_HOME 设置正确
JAVA_HOME is set correctly
执行命令 java -fullversion 有效
Executing the command java -fullversion works
$ java -fullversion
./java full version "1.7.0_05-b05"
/usr/java 中的符号链接都指向正确的 java 安装
The symbolic links in /usr/java all point to the correct java installation
我在创建系统时没有安装任何默认"java
I did not install any 'default' java when I created the system
java -version
失败...与上述相同的错误
java -version
fails...same error as above
从java安装的目录结构下发出命令也不起作用
Issuing the commands from under the directory structure of the java installation does not work either
这是 64 位 Java 的 64 位
This is 64-bit java for a 64-bit
有什么想法吗?
推荐答案
此问题源于不正确的 Java 安装.
This problem stems from an improper Java installation.
注意:此方案仅适用于 Java 8 及更早版本.从 Java 9 开始,JRE 的结构有所不同.rt.jar 和好友都不存在了,Pack200 也不再使用了.
NOTE: This scenario only applies to Java 8 and prior. Beginning with Java 9, the JRE is structured differently. rt.jar and friends no longer exist, and Pack200 is no longer used.
Java 标准库包含在各种 JAR 中,例如 rt.jar
、deploy.jar
、jsse.jar
等.打包 JRE 时,这些关键 JAR 文件会使用 Pack200 压缩并存储为 rt.pack
、deploy.pack
、jsse.pack
等.Java 安装程序应该解压缩它们.如果您遇到此错误,那显然没有发生.
The Java standard library is contained in various JARs, such as rt.jar
, deploy.jar
, jsse.jar
, etc. When the JRE is packaged, these critical JAR files are compressed with Pack200 and stored as rt.pack
, deploy.pack
, jsse.pack
, etc. The Java installer is supposed to uncompress them. If you are experiencing this error, apparently that didn't happen.
您需要手动运行 unpack200
在 JRE 的 lib/
和 lib/ext/
文件夹中的所有 .pack
文件上.
You need to manually run unpack200
on all .pack
files in the JRE's lib/
and lib/ext/
folders.
要解压一个 .pack
文件(例如 rt.pack
),请运行:
To unpack one .pack
file (for example rt.pack
), run:
"%JAVA_HOME%inunpack200" -r -v rt.pack rt.jar
要递归地解压所有 .pack
文件,请从 JRE 根运行:
To recursively unpack all .pack
files, from the JRE root run:
for /r %f in (*.pack) do "%JAVA_HOME%inunpack200.exe" -r -q "%f" "%~pf%~nf.jar"
*nix
要解压一个 .pack
文件(例如 rt.pack
),请运行:
*nix
To unpack one .pack
file (for example rt.pack
), run:
/usr/bin/unpack200 -r -v rt.pack rt.jar
要递归地解压所有 .pack
文件,请从 JRE 根运行:
To recursively unpack all .pack
files, from the JRE root run:
find -iname "*.pack" -exec sh -c "/usr/bin/unpack200 -r -q {} $(echo {} | sed 's/(.*.)pack/1jar/')" ;
可能性 2
您以其他方式错误安装了 Java.也许您安装时没有管理员权限,或者试图简单地从安装程序中提取文件.使用安装程序和/或更多权限重试.或者,如果您不想使用安装程序,请改用 .tar.gz
Java 包.
这篇关于JRE 1.7 - java 版本 - 返回:java/lang/NoClassDefFoundError:java/lang/Object的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!