This problem stems from an improper Java installation.
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.
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.
You need to manually run unpack200
on all .pack
files in the JRE's lib/
and lib/ext/
folders.
To unpack one .pack
file (for example rt.pack
), run:
"%JAVA_HOME%\bin\unpack200" -r -v rt.pack rt.jar
To recursively unpack all .pack
files, from the JRE root run:
for /r %f in (*.pack) do "%JAVA_HOME%\bin\unpack200.exe" -r -q "%f" "%~pf%~nf.jar"
To unpack one .pack
file (for example rt.pack
), run:
/usr/bin/unpack200 -r -v rt.pack rt.jar
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/')" \;
You misinstalled Java in some other way. Perhaps you installed without admin rights, or tried to simply extract files out of the installer. Try again with the installer and/or more privileges. Or, if you don't want to use the installer, use the .tar.gz
Java package instead.
For Java 8 on a *nix OS, go to <jdk root>/jre/lib
(for me, /usr/java/jdk1.8.0_05/jre/lib
). From this directory, execute:
../../bin/unpack200 rt.pack rt.jar
../../bin/unpack200 jsse.pack jsse.rar
../../bin/unpack200 charsets.pack charsets.jar
To prevent version problems in case you have another JRE installed, use the same unpack200
that ships with the JRE you are fixing – that is, from the command line, use ../../bin/unpack200
(for me, this expands to /usr/java/jdk1.8.0_05/bin/unpack200
), not just unpack200
.
It seems that for a 64 bit architecture you have to install both the 32-bit version and the 64-bit version of jre (architecture independent files as rt.jar are distributed only in the 32-bit version).
Remember then to pay attention to include the correct java executable on the global PATH environment variable.
Quick Solution for impatient people ;) On Windows machines, try this:
Go to C:\Windows\System32
directory and delete java.exe
(or rename it to something like java.exe.old
).
Since at least 1.6, there should not be a java.exe
in the Windows directory. If there is, it's a leftover from something.
A bit more reading:
I'm really suprised that a question from 2012 doesn't have an approved answer yet and I've actually encountered the same issue in 2015 on my Win 7 32-Bit OS!
So what did happen?
Basically, everything was working fine, I downloaded H2 database and when I tried to start H2 Console (Command Line)
I got:
Error occurred during initialization of VM
java/lang/NoClassDefFoundError: java/lang/Object
I found this question and I was able to confirm the same symptoms:
JAVA_HOME is set correctly:
echo %JAVA_HOME%
C:\Program Files\Java\jdk1.6.0_26
java -version
fails, while java --fullversion
works fine:
java -fullversion
java full version "1.6.0_45-b06"
SOLUTION:
Go to C:\Windows\System32
directory and delete (I actually renamed) java.exe
file!!!!
Now, I get:
java -version
java version "1.6.0_26"
Java(TM) SE Runtime Environment (build 1.6.0_26-b03)
Java HotSpot(TM) Client VM (build 20.1-b02, mixed mode, sharing)
and H2 Console (Command Line)
works fine as well!
Credits go to the last post in this forum: https://bukkit.org/threads/java-lang-noclassdeffounderror-java-lang-object.70450/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With