Hey there.
Java 17 is the required JRE to run the scanner in SonarQube v10.4+.
This means you can do a few things:
- Run your entire build using Java 17, still targeting Java 11 for your build (as you’ve done)
- Run your build with Java 11 and then switch to Java 17 before running the sonar task (docs)
# Maven build
mvn verify ...
export JAVA_HOME=/path/to/java-17
mvn sonar:sonar ...
- Upgrade to v5.0 of the SonarScanner for Maven (
org.sonarsource.scanner.maven:sonar-maven-plugin
), which supports JRE auto-provisioning – meaning you can use Java 11 and Java 17 will be downloaded from SonarQube Cloud and executed during analysis. This should be the least disruptive option!