wrong version 55.0, should be 52.0"/>
class file has wrong version 55.0, should be 52.0
问题描述
编译测试类的时候出现了因为java版本不一致导致的问题。
命令
javac -J-Duser.language=en -cp C:\dataset\d4j-spec5\2_cli\2.0\commons-cli2\src\java;org\apache\commons\cli2;C:\dataset\d4j-spec5\2_cli\2.0\commons-cli2\src\test;org\apache\commons\cli2\generated_by_chatgpt;C:\Libraries\maven-3.5.0\lib\* C:\dataset\d4j-spec5\2_cli\2.0\commons-cli2\src\test\org\apache\commons\cli2\generated_by_chatgpt\HelpFormatterTest1.java
输出
C:\dataset\d4j-spec5\2_cli\2.0\commons-cli2\src\test\org\apache\commons\cli2\generated_by_chatgpt\HelpFormatterTest1.java:9: error: cannot access HelpFormatter
import org.apachemons.cli2.util.HelpFormatter;
^
bad class file: C:\dataset\d4j-spec5\2_cli\2.0\commons-cli2\src\java\org\apache\commons\cli2\util\HelpFormatter.class
class file has wrong version 55.0, should be 52.0
Please remove or make sure it appears in the correct subdirectory of the classpath.
问题追溯
在powershell命令行查询了java和javac的版本,发现明明都是8
在vscode命令行查询也都是8。
这时我突然想到自己在几天以前为了使用一个插件,临时将JAVA_HOME改为了jdk11,过了几天才改回了8,也许是那几天编译产生了java11的类。
于是进入到项目的源码包下,将所有的.class文件删除,最终这个错误消失了。
更多推荐
class file has wrong version 55.0, should be 52.0
发布评论