最近在做本科生课程助教期间,需要运行学生提交的工程项目,在使用Eclipse运行部分Java项目时遇到以下错误提示:
Exception in thread "main" java.lang.UnsupportedClassVersionError: Main has been compiled by a more recent version of the Java Runtime (class file version 57.0), this version of the Java Runtime only recognizes class file versions up to 52.0
解决办法:
第一步:修改Java Build Path
1.右键点击项目,选择“Properties”,依次选择“Java Build Path”->“Libraries”,单击选中“JRE System Library”,然后点击“Edit”按钮进行编辑。
2.选择“Alternate JRE”或“Workspace default JRE”的jdk版本(一般应该相同)均可,点击“Finish”。
第二步:修改Java Compiler
1.选择“Java Compiler”,勾选“Enable project specific settings”,将“Compiler compliance level”设置为与jvm一致的版本(1.8)。
至此问题应该已经解决,程序可以正常运行!
参考链接:
1.https://blog.csdn.net/qq_43166758/article/details/107199789
2.https://zhidao.baidu.com/question/924785449138370779.html