处理报错:java/lang/NoClassDefFoundError: java/lang/Object

处理报错:java/lang/NoClassDefFoundError: java/lang/Object
 
 
操作系统环境:CentOS6.0 2.6.32-220.el6.x86_64
JDK版本环境:jdk1.5.0_22
操作系统原来安装的是jdk1.6,后来开发人员要求java程序使用jdk1.5版本的。帮开发下载JDK1.5,
安装完JDK ,设定环境变量后出现这个错误:

  1. [root@fztest97 lib]# javac
  2. Error occurred during initialization of VM
     
  3. java/lang/NoClassDefFoundError: java/lang/Object
     
  4. [root@fztest97 lib]# java
     
  5. Error occurred during initialization of VM
     
  6. java/lang/NoClassDefFoundError: java/lang/Object

 
首先要确认的是环境变量的设置是否正确,其次,需要确认的就是lib和jre/lib文件夹中的rt和tools是否是打包后的形式,如果发现rt.pack 和 tools.pack 那么多半问题就出在这里。
解决方法也很简单,只要将相应文件解压成rt.jar 和 tools.jar,可以使用bin里面的unpack200工具,
如:unpack200 rt.pack rt.jar
 
/apps/usr/java/jdk1.5.0_22/lib/tools.pack 转为 tools.jar 
/apps/usr/java/jdk1.5.0_22/jre/lib/rt.pack 转为 rt.jar
 
执行如下操作命令:
 

  1. [root@fztest97 ]# cd /apps/usr/java/jdk1.5.0_22/lib/
  2. [root@fztest97 lib]# unpack200 tools.pack tools.jar
     
  3. [root@fztest97 lib]# ls
     
  4. dt.jar ir.idl jconsole.jar orb.idl sa-jdi.jar tools.jar tools.pack
     
  5. [root@fztest97 lib]# cd /apps/usr/java/jdk1.5.0_22/jre/lib
     
  6. [root@fztest97 lib]# unpack200 rt.pack rt.jar
     
  7. [root@fztest97 lib]# ll rt.*
     
  8. -rw-r--r--. 1 root root 40232487 May 23 19:23 rt.jar
     
  9. -rw-r--r--. 1 root root 12960918 May 23 19:07 rt.pack



再次执行如下命令,进行验证:

  1. [root@fztest97 lib]# java -version
  2. java version "1.5.0_22"
     
  3. Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_22-b03)
     
  4. Java HotSpot(TM) 64-Bit Server VM (build 1.5.0_22-b03, mixed mode)
     

  5.  
  6. [root@fztest97 lib]# javac
     
  7. Usage: javac <options> <source files>
     
  8. where possible options include:
     
  9. -g Generate all debugging info
     
  10. -g:none Generate no debugging info
     
  11. -g:{lines,vars,source} Generate only some debugging info
     
  12. -nowarn Generate no warnings
     
  13. -verbose Output messages about what the compiler is doing
     
  14. -deprecation Output source locations where deprecated APIs are used
     
  15. -classpath <path> Specify where to find user class files
     
  16. -cp <path> Specify where to find user class files
     
  17. -sourcepath <path> Specify where to find input source files
     
  18. -bootclasspath <path> Override location of bootstrap class files
     
  19. -extdirs <dirs> Override location of installed extensions
     
  20. -endorseddirs <dirs> Override location of endorsed standards path
     
  21. -<directory> Specify where to place generated class files
     
  22. -encoding <encoding> Specify character encoding used by source files
     
  23. -source <release> Provide source compatibility with specified release
     
  24. -target <release> Generate class files for specific VM version
     
  25. -version Version information
     
  26. -help Print a synopsis of standard options
     
  27. -Print a synopsis of nonstandard options
     
  28. -J<flag> Pass <flag> directly to the runtime system

 
到此为止,JDK1.5安装配置成功。

     本文转自vcdog 51CTO博客,原文链接:http://blog.51cto.com/255361/874171 ,如需转载请自行联系原作者


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值