Problem building with Java 8 & analyzing with Java 17

We are using Jenkins to run the sonar. JDK under Jenkins is java 11. SonarQube version - 10.4.1
When we try to run this maven command clean verify under Java 8 and sonar:sonar under java 17, it is giving an error as

“Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.11.0.3922:sonar (default-cli) on project workplace-hub: Execution default-cli of goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.11.0.3922:sonar failed: An API incompatibility was encountered while executing org.sonarsource.scanner.maven:sonar-maven-plugin:3.11.0.3922: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

As per the SonarQube doc, Is it possible to build with java 8 and scan using java 17? Please advise. Thanks in advance.

Hello @thatsenthil,

Thanks for your message.

The provided error message

Stays that the class was compiled by Java version 17(class file version 61), but your runtime Java version is Java 8(class file version 52). This means you’re running the analysis on Java 8, not Java 17.

Please, make sure you’re running the analysis with Java 17.

Best,
Margarita

Hi,

maybe this helps

Gilbert

1 Like

3 posts were split to a new topic: Problems building with correct Java version