SonarQube unable to analyze project developed using older version of Java

SonarQube unable to analyze projects built using lower version of Java. We are facing issue given below.

Sonar Configurations :
SonarQube Scanner 4.2.0.1873
Java 1.8.0_272 Red Hat, Inc. (64-bit)
SonarQube server 8.5.1

Source code file using java 1.6
added argument for java version mismatch : -Dsonar.java.source=1.6

ERROR :
Exception in thread “main” java.lang.UnsupportedClassVersionError: org/sonarsource/scanner/cli/Main : Unsupported major.minor version 52.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:808)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142

Hi,

Welcome to the community!

You can compile to whatever version you like, but you need to analyze with at least Java 8.

 
HTH,
Ann

Hi

Thank you for your quick response.

As mentioned in my query, we are using Java 1.8.0_272 in our environment where sonar scanner is running.

Can you please suggest on this further?

Thanks
Swarnab

Hi Swarnab,

Is $JAVA_HOME set in your environment? And if so, does it point to a lower version than Java 8? When the scanner CLI finds JAVA_HOME it uses that instead of the embedded JVM.

 
Ann