Error: java/lang/NoClassDefFoundError: java/lang/Object
Operating system environment: CentOS6.0 2.6.32-220. el6.x86 _ 64
JDK Version environment: jdk1.5.0 _ 22
The operating system was originally installed with jdk1.6. Later, developers asked the java program to use jdk1.5. Help developers download JDK1.5,
After JDK is installed, this error occurs after environment variables are set:
The code is as follows: |
Copy code |
[Root @ fztest97 lib] # javac Error occurred during initialization of VM Java/lang/NoClassDefFoundError: java/lang/Object [Root @ fztest97 lib] # java Error occurred during initialization of VM Java/lang/NoClassDefFoundError: java/lang/Object |
First, check whether the environment variables are set correctly. Secondly, check whether the rt and tools in the lib and jre/lib folders are in the packaged form. If rt is found. pack and tools. most of the problems with pack are here.
The solution is also very simple. You only need to decompress the corresponding file into rt. jar and tools. jar, you can use the unpack200 tool in bin,
Example: unpack200 rt. pack rt. jar
The code is as follows: |
Copy code |
/Apps/usr/java/jdk1.5.0 _ 22/lib/tools. pack to convert to tools. jar /Apps/usr/java/jdk1.5.0 _ 22/jre/lib/rt. pack to rt. jar
|
Run the following command:
The code is as follows: |
Copy code |
[Root @ fztest97] # cd/apps/usr/java/jdk1.5.0 _ 22/lib/ [Root @ fztest97 lib] # unpack200 tools. pack tools. jar [Root @ fztest97 lib] # ls Dt. jar ir. idl jconsole. jar orb. idl sa-jdi.jar tools. jar tools. pack [Root @ fztest97 lib] # cd/apps/usr/java/jdk1.5.0 _ 22/jre/lib [Root @ fztest97 lib] # unpack200 rt. pack rt. jar [Root @ fztest97 lib] # ll rt .* -Rw-r --. 1 root 40232487 May 23 rt. jar -Rw-r --. 1 root 12960918 May 23 rt. pack |
Run the following command again for verification:
The code is as follows: |
Copy code |
[Root @ fztest97 lib] # java-version Java version "1.5.0 _ 22 & Prime; Java (TM) 2 Runtime Environment, Standard Edition (build 1.5.0 _ 22-b03) Java HotSpot (TM) 64-Bit Server VM (build 1.5.0 _ 22-b03, mixed mode) [Root @ fztest97 lib] # javac Usage: javac <options> <source files> Where possible options include: -G Generate all debugging info -G: none Generate no debugging info -G: {lines, vars, source} Generate only some debugging info -Nowarn Generate no warnings -Verbose Output messages about what the compiler is doing -Deprecation Output source locations where deprecated APIs are used -Classpath <path> Specify where to find user class files -Cp <path> Specify where to find user class files -Sourcepath <path> Specify where to find input source files -Bootclasspath <path> Override location of bootstrap class files -Extdirs <dirs> Override location of installed extensions -Endorseddirs <dirs> Override location of endorsed standards path -D <directory> Specify where to place generated class files -Encoding <encoding> Specify character encoding used by source files -Source <release> Provide source compatibility with specified release -Target <release> Generate class files for specific VM version -Version Version information -Help Print a synopsis of standard options -X Print a synopsis of nonstandard options -J <flag> Pass <flag> directly to the runtime system |
So far, JDK1.5 has been installed and configured successfully.