JRE 1.7 - java version - returns: java/lang/NoClas

2019-01-02 17:41发布

When running any java application, or just 'java', the jvm fails:

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

Here is a list of wrong answers:

  1. The correct Java home directory, including the /bin directory, is on the global PATH

  2. JAVA_HOME is set correctly

  3. Executing the command java -fullversion works

    $ java -fullversion
    
    ./java full version "1.7.0_05-b05"
    
  4. The symbolic links in /usr/java all point to the correct java installation

  5. I did not install any 'default' java when I created the system

  6. java -version fails...same error as above

  7. Issuing the commands from under the directory structure of the java installation does not work either

  8. This is 64-bit java for a 64-bit

Any ideas?

标签: java
27条回答
旧时光的记忆
2楼-- · 2019-01-02 17:56

This problem happens when you install the JDK by _uncompressing_ it instead of _executing_ it.

By example:

unzip jdk-6u45-linux-x64.bin  (wrong)

sh ./jdk-6u45-linux-x64.bin   (right)

In the first scenario, the runtime libraries, as rt.jar, don't get automatically uncompresessed (thus, you can find the rt.pack files, etc. instead of the .jar ones).

查看更多
初与友歌
3楼-- · 2019-01-02 17:57

So, I went on trying everything and at last it seems that reinstalling java after uninstalling it fixed my problem.

查看更多
与风俱净
4楼-- · 2019-01-02 17:57

I was facing same issue: Error occurred during initialization of VM java/lang/NoClassDefFoundError: java/lang/Object

Follow below steps to resolve issue :

Step 1. Goto C:\Program Files\ and search for Java folder.

Step 2. Delete C:\Program Files\Java folder.

Step 3. Download new Jdk for your version 32 bit/64 bit from http://www.oracle.com/technetwork/java/javase/downloads/index.html

Step 4. Install JDK

Step 5: Now Set JAVA_HOME to "C:\Program Files\Java\jdk1.8.0_91"

Step 6: Open command prompt and enter java -version.

It works.

查看更多
残风、尘缘若梦
5楼-- · 2019-01-02 17:58

You are most probably missing a file called rt.jar in your installation which has the class file for java.lang.Object. Check your install files etc.

In particular, note that a 64-bit intsaller overlays (or installs "next to") an existing 32-bit installation. In other words, to get a fully working 64-bit installation, you must first run the 32-bit installation, and follow that up with a 64-bit installation if you have a 64bit capable machine...

If instead you do just a 64-bit installation you will be missing certain files in the installation and will get errors such as the one above.

查看更多
查无此人
6楼-- · 2019-01-02 17:58

This fixed the problem I had on CentOS

sudo yum install java-1.8.0-openjdk-devel

also see setting JAVA_HOME & CLASSPATH in CentOS 6

查看更多
残风、尘缘若梦
7楼-- · 2019-01-02 17:58

On windows this works for me

C:\jdk-8u162-windows-x64\jre\lib>..\..\bin\unpack200 -r -v rt.pack rt.jar
查看更多
登录 后发表回答