# Problems building with correct Java version

**URL:** <https://community.sonarsource.com/t/problems-building-with-correct-java-version/131131>\
**Category:** SonarQube Server / Community Build\
**Created:** [November 6, 2024, 11:30am UTC](https://community.sonarsource.com/t/problems-building-with-correct-java-version/131131 "2024-11-06T11:30:09Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![thatsenthil](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/thatsenthil/32/55938_2.png) [@thatsenthil](https://community.sonarsource.com/u/thatsenthil)\
**Post date:** [November 6, 2024, 11:30am UTC](https://community.sonarsource.com/t/problems-building-with-correct-java-version/131131/1 "2024-11-06T11:30:09Z")

</div>

This is still an issue.  
Step 1 : clean install using default JDK 8 which is fine (Build is successful)  
Step 2: sonar:sonar -Dsonar.host.url=[https://sonarqube-test/sonarqube](https://sonarqube-test/sonarqube) -Dsonar.token=sqa\_XXXXXXXX -Dsonar.java.jdkHome=“C:'Program Files’\Microsoft\jdk-17.0.10+7”

Error:  
[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:4.0.0.4121:sonar (default-cli) on project my-portfolio: Execution default-cli of goal org.sonarsource.scanner.maven:sonar-maven-plugin:4.0.0.4121:sonar failed: Unable to load the mojo ‘sonar’ in the plugin ‘org.sonarsource.scanner.maven:sonar-maven-plugin:4.0.0.4121’ due to an API incompatibility: org.codehaus.plexus.component.repository.exception.ComponentLookupException: org/sonarsource/scanner/maven/SonarQubeMojo 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

As per the doc, I have used JDK 8 to build the code and JDK17 for sonar analysis but it is failed with the above error.  
Kindly, Please advise.

---

<div class="post-metadata">

**Author:** ![ganncamp](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/ganncamp/32/1261_2.png) [@ganncamp](https://community.sonarsource.com/u/ganncamp)\
**Post date:** [November 6, 2024, 5:29pm UTC](https://community.sonarsource.com/t/problems-building-with-correct-java-version/131131/2 "2024-11-06T17:29:35Z")

</div>

Hi @thatsenthil,

If you’re getting that error, then you’re not actually analyzing with Java 17. You need to take another look at how you’re switching JVMs.

&nbsp;  
Ann

---

<div class="post-metadata">

**Author:** ![thatsenthil](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/thatsenthil/32/55938_2.png) [@thatsenthil](https://community.sonarsource.com/u/thatsenthil)\
**Post date:** [November 26, 2024, 2:40pm UTC](https://community.sonarsource.com/t/problems-building-with-correct-java-version/131131/3 "2024-11-26T14:40:21Z")

</div>

I am using the below pipeline script. JDK 17 has installed, our Jenkins is running on JDK 21 and SonarQube 10.7 version bu tstill getting an error. Kindly, Please assist. Thanks in advance,

Pipeline:  
stage(‘Sonar’) {  
agent { label ‘sl16vmcj’ }  
tools {  
jdk ‘JDK-17’  
maven ‘maven-3.9.6’  
}  
when {  
expression {  
return params.RUN\_SONAR || !(IS\_RELEASE.toBoolean()) && env.BRANCH\_NAME == ‘master’  
}  
}  
options {  
timeout(time: 30, unit: ‘MINUTES’)  
}  
steps {  
bat ‘mvn org.sonarsource.scanner.maven:sonar-maven-plugin:3.9.1.2184:sonar -X’  
}  
}

Error:  
Caused by: org.apache.maven.project.DependencyResolutionException: Could not resolve dependencies for project com.ex.customer:myproject:war:2.10.359.SNAPSHOT: The following artifacts could not be resolved: jdk:tools:jar:5.0: Could not find artifact jdk:tools:jar:5.0 at specified path C:\Program Files\Microsoft\jdk-17.0.10+7/…/lib/tools.jar

---

<div class="post-metadata">

**Author:** ![thatsenthil](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/thatsenthil/32/55938_2.png) [@thatsenthil](https://community.sonarsource.com/u/thatsenthil)\
**Post date:** [November 26, 2024, 2:39pm UTC](https://community.sonarsource.com/t/problems-building-with-correct-java-version/131131/4 "2024-11-26T14:39:09Z")

</div>

I am using the below pipeline script. JDK 17 has installed, our Jenkins is running on JDK 21 and SonarQube 10.7 version bu tstill getting an error. Kindly, Please assist. Thanks in advance,

Pipeline:  
stage(‘Sonar’) {  
agent { label ‘sl16vmcj’ }  
tools {  
jdk ‘JDK-17’  
maven ‘maven-3.9.6’  
}  
when {  
expression {  
return params.RUN\_SONAR || !(IS\_RELEASE.toBoolean()) && env.BRANCH\_NAME == ‘master’  
}  
}  
options {  
timeout(time: 30, unit: ‘MINUTES’)  
}  
steps {  
bat ‘mvn org.sonarsource.scanner.maven:sonar-maven-plugin:3.9.1.2184:sonar -X’  
}  
}

Error:  
Caused by: org.apache.maven.project.DependencyResolutionException: Could not resolve dependencies for project com.ex.customer:myproject:war:2.10.359.SNAPSHOT: The following artifacts could not be resolved: jdk:tools:jar:5.0: Could not find artifact jdk:tools:jar:5.0 at specified path C:\Program Files\Microsoft\jdk-17.0.10+7/…/lib/tools.jar

---

<div class="post-metadata">

**Author:** ![ganncamp](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/ganncamp/32/1261_2.png) [@ganncamp](https://community.sonarsource.com/u/ganncamp)\
**Post date:** [November 26, 2024, 3:42pm UTC](https://community.sonarsource.com/t/problems-building-with-correct-java-version/131131/5 "2024-11-26T15:42:23Z")

</div>

Hi,

I’ve consolidated your posts on this topic into a new thread. You’ve now resurrected two stale threads. I should have said something the first time you did it, but let it slide. My mistake.

Per [the FAQ](https://community.sonarsource.com/faq), please don’t do that again.

Based on Googling your error, you seem to be [using a JRE where a JDK is needed](https://stackoverflow.com/a/34220439/2662707).

&nbsp;  
HTH,  
Ann
