About Me

My photo
I know the last digit of PI

Thursday, April 11, 2013

Error occurred during initialization of VM java/lang/NoClassDefFoundError: java/lang/Object

C:\>java -version
Error occurred during initialization of VM
java/lang/NoClassDefFoundError: java/lang/Object
First thing is to find out which java is used
c:\>where java.exe
C:\Windows\System32\java.exe
Ok this is the java wrapper that reads the registry and sets the JAVA_HOME from there. Open registry editor and go to the keys (replace 1.7 with the latest major version) HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment\1.7 HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment\1.7.0_17

Change the JavaHome to point to correct path.
Currently it is pointing to C:\Program Files\java\jre7. Alternativly you can use C:\Program Files\java\jdk1.7.0_17\jre
You can create a java.reg file and import it into registry.
Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment\1.7]

"JavaHome"="C:\\Program Files\\Java\\jdk1.7.0_17\\jre"
In my case the problem was faulty installation of the JRE.
I have two options:
  1. either live with alternative path C:\Program Files\java\jdk1.7.0_17\jre
  2. I can repair the JRE installation.

I choose option 2, so I copied everything from C:\Program Files\Java\jdk1.7.0_17\jre to C:\Program Files\java\jre7 (overriding the files).

No comments: