Eclipse中的java.lang.UnsupportedClassVersionError [英] java.lang.UnsupportedClassVersionError in eclipse

查看:75
本文介绍了Eclipse中的java.lang.UnsupportedClassVersionError的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不是一个Java程序员,所以我发贴这个问题。在eclipse项目的主类中抛出异常java.lang.UnsupportedClassVersionError。如果我注释了这个类的导入,它编译并运行正常。如果我重新进入导入,它不起作用。这是否意味着我正在导入的图书馆是使用比我有的更新或更旧版本的java编译的?当我在系统上执行java -version时,我得到1.5_07



我可以宣誓就是上周实际工作,但也许eclipse中的某些设置会被调整? Eclipse中的Java Build Path是否需要查找JRE和编译器版本?

解决方案

在Eclipse中,编译器版本独立于JRE版本。这意味着您可以将编译器设置为Java 1.6版,并使用JRE 1.5。在这种情况下,您编译的类无法运行。



您可以在窗口/首选项/ Java /编译器用于默认编译器合规性级别,或项目属性,用于特定于项目的编译器级别。将该级别与项目中使用的JRE(项目/属性/ Java构建路径 - >库/ JRE系统库)和程序的启动配置(通过运行/运行配置... 菜单)。


I am not a Java programmer really, so I am posting this question. The exception is being thrown java.lang.UnsupportedClassVersionError in my main class in an eclipse project. If I comment out the imports that this class has, it compiles and runs fine. If I put the imports back in, it does not work. Does this mean that the libraries I am importing were compiled with a newer or older version of java than I have? when i do java -version on the system i get 1.5_07

I could've sworn this was actually working last week, but maybe some setting in eclipse got tweaked? Is the Java Build Path in eclipse what I need to look for to check the JRE and compiler versions?

解决方案

In Eclipse, the compiler version is set independent of the JRE version. That means you can set the compiler to Java version 1.6 and use the JRE 1.5. In this case, you compiled classes cannot be run.

You can check the preferences in Window / Preferences / Java / Compiler for the default compiler compliance level, or the properties of your project for a project specific compiler compliance level. Compare that level with the JRE used in your project (Project / Properties / Java Build Path -> Libraries / JRE System Library) and in your program's launch configuration (via the Run / Run Configurations... menu).

这篇关于Eclipse中的java.lang.UnsupportedClassVersionError的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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