您的位置:首页 > 编程语言 > Java开发

Eclipse 运行项目抛UnsupportedClassVersionError弹出yunCould not find the main class.program will exit

2013-07-07 09:28 651 查看
出现Could not find the main class.program will exit和java.lang.UnsupportedClassVersionError 错误的原因,是因为我们使用高版本的JDK编译的Java class文件试图在较低版本的JVM上运行,所报的错误。

因为,高版本的JDK生成的class文件使用的格式,可能与低版本的JDK的.class文件格式不同。这样,低版本的JVM无法解释执行这个.class文件,会抛出Could not find the main class.program will exit,java.lang.UnsupportedClassVersionError不支持的Class版本错误。

eclipse下有几个需要使用jre的地方。第一个是编译器使用,第二个是开发使用,第三个是运行时使用。

遗憾的是这三个是需要分别配置的,你的问题就在于eclipse的这三个包之间有版本冲突!

Windows->Proferences->java-> Installs Jres重新设置JDK路径

Windows->Proferences->java->Compiler,将compiler compliance level设置为与上面相同的JDK

这样试了一下还是不行,发现对于项目来说,compiler compliance level也有不同,

Windows->Proferences->java->Compiler->config project specific settings
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐