[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.10.0.2594:sonar (default-cli) on project demo: Execution default-cli of goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.10.0.2594:sonar failed: An API incompatibility was encountered while executing org.sonarsource.scanner.maven:sonar-maven-plugin:3.10.0.2594:sonar: java.lang.UnsupportedClassVersionError: org/sonar/batch/bootstrapper/EnvironmentInformation has been compiled by a more recent version of the Java Runtime (class file version 61.0), this version of the Java Runtime only recognizes class file versions up to 52.0
the sonar.java.jdkHome property is used to specify which JDK classes the analyzer must refer to during the analysis, ensuring consistent and accurate issue reporting, especially in relation to native JDK classes.
You didn’t mention your Sonarqube version, but i guess it’s latest as class file version 61.0 means you need to run the Sonarqube scan with Java 17.
You may compile with Java 8, but the maven sonar:sonar goal needs to run with Java 17.
In our Jenkins pipelines, we use one Maven CLI call for the build and another one for the Sonarqube analysis via sonar:sonar that runs always with Java 17.
Yea my sonarqube is the latest, so what do you suggest me to do?
I’ve changed sonar.java.jdkHome to temurin-17-jdk-amd64 and still has the error about JavaRuntime.
The sonar.java.jdkHome property is only some extra information for the analysis.
But the analysis itself has to run with Java 17, when in your case it runs with Java 8 (class version 52.0)