SonarScanner, Java Runtime Error

Sonarqube version: 10.4.1 ((build 88267)
Sonar Scanner version:
SonarQube deployed: Docker

Trying to run the sonar scanner script to our project but the below error is showing up:

ERROR: Error during SonarScanner execution
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

Checked the sonar scanner and it is still using the java 11
INFO: SonarScanner
INFO: Java 11.0.3 AdoptOpenJDK (64-bit)

But we have the below java version in our CentOS 7 VM:
java --version
java 17.0.6 2023-01-17 LTS

How can we update the java path for the sonarscanner?

We’ve tried to modify the file /opt/sonar-scanner-
and add the JAVA_HOME variable in it but still didn’t work.


Your scanner version is rather old at this point, and given that your installed Java version is 17, I suspect your scanner install is one with a bundled JVM.

Upgrade the scanner and you should be good.