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

来源:互联网 发布:知乎百万英镑 编辑:程序博客网 时间:2024/06/05 03:58

出现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

原创粉丝点击