在使用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完后,再次试验编译成功