Tag Archives: Gradle Compile Error

Gradle Compile Error: compileJava FAILED [How to Solve]

When using gradle project, the following situations occur during the process of building a file:

> 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

According to the above error conditions:

“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.”

It is possible to know that the problem occurs in the idea-program/avro-car-sensor-simulator-master/device-simulator-plugin-sdk-1.0.0.jar, which requires version 55, while the current environment is version 52.
(Reason for the error: running a class file compiled with a JDK of 11 using a JRE with a JDK of 8)

The corresponding version of Java is as follows:

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

After configuring java11, try again and compile successfully