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:45

I had the same problem recently. In my case my windows 7 machine automatically downloaded java and added C:\ProgramData\Oracle\Java\javapath to the beginning of my path environment variable, which messed up my java. Once I got rid of that from the path, it worked.

查看更多
路过你的时光
3楼-- · 2019-01-02 17:46

I have the some problem on x86_64 Linux installations with JDK 1.7.0_40 i586. I figured out that the problem is that rpm can't unpack jar files, as mentioned by Rigg802 (though rpm completes marking success):

Unpacking JAR files...
        rt.jar...
/var/tmp/rpm-tmp.zLzkkb: /usr/java/jdk1.7.0_40/bin/unpack200: /lib/ld-linux.so.2: bad ELF interpreter: No such file or directory
Error: unpack could not create JAR file:

        /usr/java/jdk1.7.0_40/jre/lib/rt.jar

File /lib/ld-linux.so.2 is provided by glibc-2.12-1.107.el6_4.4.i686 which is not among rpm deps of jdk rpm.

Oracle JDK rpm also requires 32 bit versions of libgcc-4.4.7-3.el6.i686 to be installed

So, workaround is to install glibc-2.12-1.107.el6_4.4.i686 and libgcc-4.4.7-3.el6.i686 first.

查看更多
与君花间醉酒
4楼-- · 2019-01-02 17:47

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.

查看更多
春风洒进眼中
5楼-- · 2019-01-02 17:47

I faced same issue, I have installed two java version hence it caused this issue. to confirm this go and click java icon in control panel if doesnt open then issue is same, just go and uninstall one version. piece of cake. thanks.

查看更多
春风洒进眼中
6楼-- · 2019-01-02 17:50

I found that this error occurred when I extracted the .rpm file.

I then removed that folder and downloaded jdk-7u79-linux-x64.tar.gz for Linux 64 and extracted the contents of this file instead. Also: export JAVA_HOME=/opt/java/jdk1.7.0_79 export JDK_HOME=/opt/java/jdk1.7.0_79 export PATH=${JAVA_HOME}/bin

查看更多
查无此人
7楼-- · 2019-01-02 17:51

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.

查看更多
登录 后发表回答