Sonarqube 8.1 with Java 8 code

We have Java code that compiles and runs well with Java 8.
We installed Sonarqube 8.1 server (which uses Java 11) with all the latest plugins (including SonarJava plugin version 6.0.1) and tried to run analysis for above code.

There seems to be a dependency on Java 11 when running the sonar maven profile.

*Caused by: java.lang.UnsupportedClassVersionError: com/github/_1c_syntax/bsl/sonar/BSLPlugin 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

Is there a hard dependency requiring code base to be compatible with Java 11?
Even if the sonar scanner itself requires Java 11 to run, we want code to be compiled and built using Java 8. Also, tools like Jenkins/TeamCity seem to have options to specify which JDK to use in the maven and Sonarqube plugin steps.

What is the best way to go abt this? Please advise.

Hi,

Welcome to the community!

Your code doesn’t need to be compatible with Java 11, nor compiled with it. It only needs to be analyzed with it.

 
HTH,
Ann

1 Like

OK. So that should mean no disruption to any other code-related processes. Thank you.

We use Jenkins-Sonar plugin as shown in attached.

.
Default JDK (and $JAVA_HOME environment variable) point to Java 8 on the machine. Since Sonarqube requires Java 11, we can leave the JDK field in the Jenkins step empty and assume sonar-scanner will take care of it automatically? Or we need to point to an installed JDK 11 on the machine?

And how to go abt it if one were attempting this directly through maven itself having multiple goals like compile, sonar, etc.?

Apologies if some questions seem naive; am just get started with this.

1 Like

Hi,

You’ll want to install a JDK 11 and point to it via that input you’ve highlighted.

 
HTH,
Ann

1 Like