Error java.lang.UnsupportedClassVersionError when compiling Java 8 project with Sonarqube 9

Hi everyone,

I’m using the following configuration:

  • Sonarqube: 9.9-Community version
  • Maven Plugin 3.9.1.2184
  • Java 11

Since my project uses Java 8, I configured maven.compiler.source and mave.compiler.target versions to 1.8 but whenever I tried to uses sonar I get the error:

Caused by: 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 already used -Dsonar.java.jdkHome=/usr/lib/jvm/java-8-openjdk/ property to set Java 8 home directory. However, the error remains.

Any suggestions?

Hi,

It seems that you’re not just compiling to Java 8, you’re compiling - and running analysis with Java 8. As evidenced by this.

Per the docs, you have to run the analysis with Java 11 or 17.

 
HTH,
Ann

Thanks @ganncamp!

As you said I was using a image from Openshift which uses Java 8 instead of Java 11 or 17.

When I updated the image, it worked out.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.