5

I have installed latest version of SonarQube using Java 11 pointed from its config i.e. wrapper.config. I have read that it can analyze code even written in Java 8, but I am getting following exception:

[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.8.0.2131:sonar (default-cli) on project ptf-parent: Execution default-cli of goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.8.0.2131:sonar failed: An API incompatibility was encountered while executing org.sonarsource.scanner.maven:sonar-maven-plugin:3.8.0.2131:sonar: 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

Currently, my code is build using Java 8 and I want to analyze using the latest SonarQube version.

I am running analyzer from Eclipse IDE. All my projects are configured to use Java 8 and Maven 3.8.2 to use sonar parameters to push report on SonarQube, but it does not work.

Below are the parameters I am providing in Eclipse Run as Maven build:

 -e clean install sonar:sonar -Dsonar.java.jdkHome=C:\Program Files\Java\jdk1.8.0_251 -Dsonar.project
-Dsonar.projectKey=TESTPROJECT -Dsonar.host.url=http://localhost:9000 -Dsonar.login=a2603f6cd079e4a7833179333333333333333333e
Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
usman
  • 1,351
  • 5
  • 23
  • 47
  • You can have a different java version for the project, by providing the proper java home following the docs: https://docs.sonarqube.org/latest/analysis/languages/java/ – Mario Santini Sep 22 '21 at 09:32
  • i have made java_home to JDK 11 but does not work. – usman Sep 22 '21 at 11:39
  • You have to read the _Project's specific JDK_ paragraph and set the `sonar.java.jdkHome` to the Java 8 JDK installation, if your project use Java 8. – Mario Santini Sep 22 '21 at 12:53
  • check my edited question above, In maven params while running from eclipse i am providing it. but it remains same. Let me know if i am missing some thing. – usman Sep 22 '21 at 14:06
  • I see now you're using Maven, the documentation tell that in this case you don't have to set nothing. If the project is properly configured and build with Maven in Java 8, you just need to run the plugin. And remove the configuration. – Mario Santini Sep 22 '21 at 14:13
  • that does not work for me. i can remove jdkHome parameter and still the result is same. do i have to set some thing in POM ? – usman Sep 22 '21 at 14:22
  • You should have already set the Java version on the pom file _maven.compiler.target_ and _maven.compiler.source_ in the properties section. – Mario Santini Sep 22 '21 at 14:29

1 Answers1

0

According to sonarqube community, you should try the following:

Edit conf\wrapper.conf, specifically the wrapper.java.command to following:

wrapper.java.command=C:\Program Files\Java\open jdk-11.0.2\bin\java 
#wrapper.java.command=java
Djordje Nedovic
  • 559
  • 8
  • 20