Java8 is not compile for my project

[Pipeline] withSonarQubeEnv
Injecting SonarQube environment variables using the configuration: Sonar1
[Pipeline] {
[Pipeline] sh

  • /opt/gradle/gradle-4.8.1/bin/gradle sonarqube -Dsonar.projectKey=CubeSchemesAppService -Dsonar.java.jdkHome=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.302.b08-0.el7_9.x86_64 -Dsonar.projectName=CubeSchemesAppService -Dsonar.projectVersion=10.0 -Dsonar.host.url=http://172.188.9.3:9000/sonar -Dsonar.login=****** ‘-Dsonar.password=******’ -Dsonar.sources=/var/lib/jenkins/workspace/Cubescheme-master/src/ -Dsonar.java.binaries=/var/lib/jenkins/workspace/Cubescheme-master/build/classes/ -Dsonar.sonar.java.libraries=/var/lib/jenkins/workspace/Cubescheme-master/build/distributions/ -Dsonar.language=java -Dsonar.sourceEncoding=UTF-8 -Dsonar.verbose=true

Task :compileJava UP-TO-DATE
Task :processResources UP-TO-DATE
Task :classes UP-TO-DATE
Task :compileTestJava

Task :sonarqube FAILED

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ‘:sonarqube’.

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

  • Try:

Hi,

means you started a java application that was compiled with Java11 (class file version 55.0) for
target > Java 8 with Java 8 (class file version 52.0). It has to be started with Java 11 instead.

Gilbert

How to change java runtime 8(java 8) while scanning.(present version is 9.0 with java 11)

You need to either adapt the sonar.java.jdkHome to Java11

or run Gradle with Java11, then sonar.java.jdkHome property is unnecessary.
see also https://docs.sonarqube.org/latest/analysis/analysis-with-java-11/

should java 8 be in sonar server and i need mention the path.

-Dsonar.java.jdkHome=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.302.b08-0.el7_9.x86_64

You didn’t mention your Sonarqube version, assumed it is a more recent version.
Means your Sonarqube server should already run with Java 11, see
https://docs.sonarqube.org/latest/requirements/requirements/

But the analysis - seems to be with Gradle in your case - typically runs on another machine, i.e. in a Jenkins pipeline or similar.
So you need to adjust it on the machine where analysis runs.

HI SonarSource,

I have used the below lines, but not compiling with java 8 .

You need to use Java11 instead of Java8, means something like
-Dsonar.java.jdkHome = /usr/lib/jvm/java-11-openjdk

HI SonarSource,

I want to use java 8 for my application while using sonar scanner it taking java 11 as give the error.

You may use Java8, but Sonar scanner has to be run with Java11
which is set via -Dsonar.java.jdkHome = /usr/lib/jvm/java-11-openjdk
Did you already try this ?

hi SonarSource,

yes did the same, but same response.

/opt/gradle/gradle-4.8.1/bin/gradle sonarqube -Dsonar.projectKey=CubeSchemesAppService ‘-Dsonar.java.jdkHome=C:\Program Files\Java\jdk-11.0.10’ -Dsonar.projectName=CubeSchemesAppService -Dsonar.projectVersion=10.0 -Dsonar.host.url=http://192.168.201.199:9000/sonar -Dsonar.login=cscsdsdaff ‘-Dsonar.password=8888888888!!’ -Dsonar.sources=/var/lib/jenkins/workspace/Cubescheme-master/src/ -Dsonar.java.binaries=/var/lib/jenkins/workspace/Cubescheme-master/build/classes/ -Dsonar.sonar.java.libraries=/var/lib/jenkins/workspace/Cubescheme-master/build/distributions/ -Dsonar.language=java -Dsonar.sourceEncoding=UTF-8 -Dsonar.verbose=true

Task :compileJava UP-TO-DATE
Task :processResources UP-TO-DATE
Task :classes UP-TO-DATE
Task :compileTestJava
Task :sonarqube FAILED

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ‘:sonarqube’.

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

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

BUILD FAILED in 2s

is a unix path, whereas this is a windows path

Are you sure this path is correct !?
Your Jenkins seems to run on linux.

hi SonarSource,

Still the same issue.

Once more request in developer edition can we pull analysis report for projects.