Getting UnsupportedClassVersionError

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube Server ): v2025.1
  • how is SonarQube deployed: Docker
  • what are you trying to achieve? Upgrade Sonarqube server to latest
  • what have you tried so far to achieve this?
    We upgraded sonarqube server to v2025.1 version and then tried to connect for processing code using the latest sonar-scanner cli (version 7.0.2.4839)
    However we get the following error even while checking version of cli:
Run $GITHUB_WORKSPACE/sonar-scanner-7.0.2.4839/bin/sonar-scanner --version || echo "SonarScanner not found. Make sure to run it from $GITHUB_WORKSPACE/sonar-scanner-7.0.2.4839/bin/sonar-scanner"
  $GITHUB_WORKSPACE/sonar-scanner-7.0.2.4839/bin/sonar-scanner --version || echo "SonarScanner not found. Make sure to run it from $GITHUB_WORKSPACE/sonar-scanner-7.0.2.4839/bin/sonar-scanner"
  shell: /usr/bin/bash -e {0}
  
Error: LinkageError occurred while loading main class org.sonarsource.scanner.cli.Main
	java.lang.UnsupportedClassVersionError: org/sonarsource/scanner/cli/Main 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
SonarScanner not found. Make sure to run it from /home/runner/runner/agent/_work/sonarqube-internal/sonarqube-internal/sonar-scanner-7.0.2.4839/bin/sonar-scanner

The env on which the sonar-scanner cli is running has openjdk-11 installed.
However this documentation says (SonarScanner requirements | SonarQube Server Documentation) the cli versions greater than 6.0 don’t require Java 17 explicitly installed. The JRE is auto-provisioned but we are still getting this error.

Any clues on how to fix this without upgrading to Java 17 would be of great help because I think that would be less disruptive.

Do not share screenshots of logs – share the text itself (bonus points for being well-formatted)!

Hi,

Is $JAVA_HOME defined in your environment? Also, do you have a $use_embedded_jre variable?

 
Ann