SonarScanner CLI error


We are trying to use Sonarscanner to scan a Java Maven project to the Sonarcloud destination.

It is throwing the following error:
08:04:31.303 ERROR: Error during SonarQube Scanner execution

java.lang.UnsupportedClassVersionError: org/sonar/batch/bootstrapper/EnvironmentInformation has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0

I have Java in the path variable and using the JDK version 17.0.1

What is the issue and how to resolve?

Hey there.

This indicates that somewhere, Java 8 is being used to run Maven. Appending -X to your Maven command should give you a pretty quick idea what version of Java is actually being used.

**❯** mvn -X
**Apache Maven 3.5.4 (1edded0938998edf8bf061f1ceb3cfdeccf443fe; 2018-06-17T20:33:14+02:00)**
Maven home: /usr/local/Cellar/maven/3.5.4/libexec
Java version: 16.0.1, vendor: AdoptOpenJDK, runtime: /Library/Java/JavaVirtualMachines/adoptopenjdk-16.jdk/Contents/Home
Default locale: en_CH, platform encoding: UTF-8
OS name: "mac os x", version: "10.16", arch: "x86_64", family: "mac"