class file has wrong version 55.0, should be 52.0

编程入门 行业动态 更新时间:2024-10-23 01:49:40

class file has <a href=https://www.elefans.com/category/jswz/34/1764262.html style=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

本文发布于:2023-12-04 20:28:01,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1662124.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:wrong   file   class   version

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!