Bad version number in .class file 错误原因

 

在用eclipse+myeclipse做Web service实例时,编译总是提示“Bad version number in .class file”,导致执行web service deploy总会提示错误,花了好大劲才知道原因是“Java Compile Level和指定编译的JRE两者间的版本不一致导致'”按以下步骤修改eclipse设置即可恢复正常。

eclisep--preferences--java--Compiler里面的Compiler compilance settings 要选和jdk一样的版本,jdk1.5要选5.0

出现的错误如下: java.lang.UnsupportedClassVersionError: Bad version number in .class file  at java.lang.ClassLoader.defineClass1(Native Method)  at java.lang.ClassLoader.defineClass(Unknown Source)  at java.security.SecureClassLoader.defineClass(Unknown Source)  at java.net.URLClassLoader.defineClass(Unknown Source)  at java.net.URLClassLoader.access$100(Unknown Source)  at java.net.URLClassLoader$1.run(Unknown Source)  at java.security.AccessController.doPrivileged(Native Method)  at java.net.URLClassLoader.findClass(Unknown Source)  at java.lang.ClassLoader.loadClass(Unknown Source)



This error is reported when someone is trying to deploy war which contains java files which have been compiled by jdk version which is lower than the jdk version which the tomcat uses.For example we compiled java files using jdk 1.4 and now we are trying to deploy it in tomcat which uses jdk 1.5.
Solution is either make tomcat uses older version of jdk or again create java class files using the version that is being used by tomcat.
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值