What to do when "java.lang.UnsupportedClassVersionError"?

  • Using Community Edition Version 9.4 (build 54424)
  • Trying to scan a .NET Framework app
  • Have tried Docker image, then tried zip version on another server

When I sent the scan from VS2022 to SQ, I get the following and don’t know what to do. I am a C# dev, not a Java dev, so I have no idea.

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 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0

Running OpenJDK 17 on both SQ and on my dev machine.

Hey there.

It sure looks like Java 8 is being used to run the analysis rather than Java 17.

Try running java --version on your local machine to see what version is being picked up by default. It may be the first in your PATH or whatever is set as the JAVA_HOME environment variable.

I had checked that, it was OpenJDK 17.x. I also tried with the Docker image, so really puzzled why that image didn’t have the correct version of Java?

Also tried spinning up a fresh Ubuntu VM, installing OpenJDK 11, and installing SQ from the .zip version and that didn’t work either.