操作系統(tǒng)環(huán)境:CentOS6.0? 2.6.32-220.el6.x86_64
JDK版本環(huán)境:jdk1.5.0_22 操作系統(tǒng)原來安裝的是jdk1.6,后來開發(fā)人員要求java程序使用jdk1.5版本的。幫開發(fā)下載JDK1.5,
安裝完JDK ,設(shè)定環(huán)境變量后出現(xiàn)這個錯誤:
[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 首先要確認(rèn)的是環(huán)境變量的設(shè)置是否正確,其次,需要確認(rèn)的就是lib和jre/lib文件夾中的rt和tools是否是打包后的形式,如果發(fā)現(xiàn)rt.pack 和 tools.pack 那么多半問題就出在這里。
解決方法也很簡單,只要將相應(yīng)文件解壓成rt.jar 和 tools.jar,可以使用bin里面的unpack200工具,
如:unpack200 rt.pack rt.jar /apps/usr/java/jdk1.5.0_22/lib/tools.pack? 轉(zhuǎn)為? tools.jar???
/apps/usr/java/jdk1.5.0_22/jre/lib/rt.pack?? 轉(zhuǎn)為? rt.jar 執(zhí)行如下操作命令:
[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--r--.?1 root root 40232487 May 23 19:23 rt.jar
-rw-r--r--.?1 root root 12960918 May 23 19:07 rt.pack ?
再次執(zhí)行如下命令,進行驗證:
[root@fztest97 lib]#?java?-version
java version?"1.5.0_22"
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 到此為止,JDK1.5安裝配置成功。
總結(jié)
以上是生活随笔為你收集整理的处理报错:java/lang/NoClassDefFoundError: java/lang/Object的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。