在使用gradle项目时,build一个文件过程中出现以下情况:

> Task :compileJava
/home/user_1/idea-program/avro-car-sensor-simulator-master/src/main/java/com/hivemq/CarDataPayloadGenerator.java:7: error: cannot access PluginPayloadGenerator
import com.hivemq.simulator.plugin.sdk.load.generators.PluginPayloadGenerator;
                                                      ^
  bad class file: /home/user_1/idea-program/avro-car-sensor-simulator-master/device-simulator-plugin-sdk-1.0.0.jar(com/hivemq/simulator/plugin/sdk/load/generators/PluginPayloadGenerator.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.

> Task :compileJava FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':compileJava'.
> Compilation failed; see the compiler error output for details.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

根据上述错误情况:

“bad class file: /home/user_1/idea-program/avro-car-sensor-simulator-master/device-simulator-plugin-sdk-1.0.0.jar(com/hivemq/simulator/plugin/sdk/load/generators/PluginPayloadGenerator.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.”

可以知道在idea-program/avro-car-sensor-simulator-master/device-simulator-plugin-sdk-1.0.0.jar内出现问题,该文件需要的是55版本,而当前环境为52版本。
(错误原因:使用JDK为8的JRE运行JDK为11编译的class文件)

Java对应的版本如下:

ava SE 13 = 57,
Java SE 12 = 56,
Java SE 11 = 55,
Java SE 10 = 54,
Java SE 9 = 53,
Java SE 8 = 52,
Java SE 7 = 51,
Java SE 6.0 = 50,
Java SE 5.0 = 49,
JDK 1.4 = 48,
JDK 1.3 = 47,
JDK 1.2 = 46,
JDK 1.1 = 45

参考文档:https://bbs.csdn.net/topics/310004779

配置JAVA11完后,再次试验编译成功

Logo

开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!

更多推荐