UnsupportedClassVersionError - JDK具有相同的版本 [英] UnsupportedClassVersionError - JDKs have same version

查看:147
本文介绍了UnsupportedClassVersionError - JDK具有相同的版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用一个现有的,旧的,Java代码库并更改了一个类。我在Java 1.5.0中重新编译了代码库。然后我成功地在Tomcat上部署此代码。

I have taking an existing, old, Java code base and changed one class. I have recompiled the code base in Java 1.5.0. I then successfully deploy this code on Tomcat.

要测试我的部署,我发送一条消息到我的应用程序,我碰到一个错误,我改变了类。

To test my deployment, I send a message to my application and I hit an error with the class that I changed.


在ServletContext资源中加载名为'myClass'的bean时,错误[com.MyClass]
[/ WEB-INF /ApplicationContext.xml]:problem
类文件或依赖类;嵌套异常是
java.lang.UnsupportedClassVersionError:(com / MyClass)bad major
version at offset = 6

Error loading class [com.MyClass] for bean with name 'myClass' defined in ServletContext resource [/WEB-INF/ApplicationContext.xml]: problem with class file or dependent class; nested exception is java.lang.UnsupportedClassVersionError: (com/MyClass) bad major version at offset=6

我检查了部署的Ear和War的清单文件,并且都有1.5.0_22-b03。 Tomcat实例上的版本是1.5.0。

I have checked the deployed Ear and War's manifest files and both have 1.5.0_22-b03. The version on the Tomcat instance is 1.5.0.

任何人都能告诉我为什么会收到这个错误?

Can anyone tell me why I'm getting this error? The JDK running the application is the same version that the code was compiled on.

奇怪的是,唯一存在错误的类是我修改的类。

Strangely, the only class that has the error is the class I amended.

推荐答案

似乎你已经使用高于1.5的Java版本编译代码。您应该检查是否安装了正确的JRE( Window - > Preferences - > Java

Seems as you have compiled your code with a higher Java version than 1.5. You should check if you have the right JRE installed (Window -> Preferences -> Java -> Installed JREs).

您还应该检查编译器符合性级别设置为1.5( Window - > 首选项 - > Java - > Compiler )。

You should also check if the Compiler compliance level is set to 1.5 (Window -> Preferences -> Java -> Compiler).

我假设你使用的是Eclipse ...

I'm assuming you are using Eclipse...

这篇关于UnsupportedClassVersionError - JDK具有相同的版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆