Sonar code compilcation

I am scanning my JDK 8 project. In sonar code analysis pipelines we are using JDK 11.

I am getting this error currently…I am using sonar version 10.4.1

Execution default-cli of goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.9.0.2155:sonar failed: An API incompatibility was encountered while executing org.sonarsource.scanner.maven:sonar-maven-plugin:3.9.0.2155: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 55.0

What could be the issues? I tried changing jdk versions in pipelines and tried to use sonar.java.source=11 as per the docs…

can anyone suggest what is the procedure here i need to follow to analyze my jdk 8 project with sonar version 10.4.1 ?

Hey there.

Take a look at the documentation on Scanner Environment

Maven / Gradle

If your whole Maven or Gradle build doesn’t run on Java 17, we suggest first to try to base the whole build on one of those versions of Java. If it’s not compatible, then you can override the JAVA_HOME environment variable just before the analysis step, as shown here:

# Maven
mvn verify ...
export JAVA_HOME=/path/to/java17
mvn sonar:sonar ...