Eclipse中的java.lang.UnsupportedClassVersionError [英] java.lang.UnsupportedClassVersionError in eclipse
问题描述
我可以宣誓就是上周实际工作,但也许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屋!