# Run SonarQube Azure Devops Scanner using OpenJDK 17

**URL:** <https://community.sonarsource.com/t/run-sonarqube-azure-devops-scanner-using-openjdk-17/78724>\
**Category:** SonarQube Server / Community Build\
**Created:** [December 12, 2022, 3:05am UTC](https://community.sonarsource.com/t/run-sonarqube-azure-devops-scanner-using-openjdk-17/78724 "2022-12-12T03:05:26Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![christopher9](https://avatars.discourse-cdn.com/v4/letter/c/9d8465/32.png) [@christopher9](https://community.sonarsource.com/u/christopher9)\
**Post date:** [December 12, 2022, 3:05am UTC](https://community.sonarsource.com/t/run-sonarqube-azure-devops-scanner-using-openjdk-17/78724/1 "2022-12-12T03:05:26Z")

</div>

- which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)  
SonarQube 9.7, SonarScanner 4.7.0.2747, Azure DevOps plugins.

The Microsoft agent where I’m running the SonarQube scanner is using Java 1.8 by default, which fails the scanner execution with the following error:

##[error]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

I installed OpenJDK 17 on the build agent to use it for the scanner execution, according to the below topic link, **if the JAVA\_HOME\_11\_X64 is available, then it will be used for the analysis only** , is this the same case using OpenJDK 17? For example, can I set the variable “JAVA\_HOME\_17\_X64” and the scanner will use that version automatically?

If not, how can I select OpenJDK 17 version just for the Sonar scanner execution using the Azure DevOps plugin (Run Code Analysis)?  
Right now I can not override the JAVA\_HOME for the whole pipeline as there are other tasks or build that depend on Java 1.8 (Maven)

[Older default java version used with Azure devops Hosted agent](https://community.sonarsource.com/t/older-default-java-version-used-with-azure-devops-hosted-agent/25243)?

Any help or suggestion would be appreciated, thanks

---

<div class="post-metadata">

**Author:** ![mickaelcaro](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/mickaelcaro/32/4147_2.png) [@mickaelcaro](https://community.sonarsource.com/u/mickaelcaro)\
**Post date:** [December 19, 2022, 7:43am UTC](https://community.sonarsource.com/t/run-sonarqube-azure-devops-scanner-using-openjdk-17/78724/3 "2022-12-19T07:43:13Z")

</div>

Hi @christopher9 ,

No currently the JAVA\_HOME\_17\_X64 variable is not supported yet. I created an entry in our backlog for this : [[VSTS-294] - Jira](https://sonarsource.atlassian.net/browse/VSTS-294)

On your side, I think the easiest way would probably be to set JAVA\_HOME to point to your java 17 installation just before the Run code analysis task, and revert it to its original value just after the analysis.  
Or you can set the JAVA\_HOME\_11\_X64 variable to point to your JAVA 17 install path, but I would not recommend this other than just for a workaround.

Would that help ?

Thanks.  
Mickaël

---

<div class="post-metadata">

**Author:** ![christopher9](https://avatars.discourse-cdn.com/v4/letter/c/9d8465/32.png) [@christopher9](https://community.sonarsource.com/u/christopher9)\
**Post date:** [December 19, 2022, 1:08pm UTC](https://community.sonarsource.com/t/run-sonarqube-azure-devops-scanner-using-openjdk-17/78724/5 "2022-12-19T13:08:05Z")

</div>

Hi @mickaelcaro

Thanks for creating the ticket to support JAVA\_HOME\_17\_X64.

Do you have any guidance or steps to set JAVA\_HOME to version 17 before the Run code analysis and revert it to the default version using pipeline tasks?

Thanks,  
Christopher

---

<div class="post-metadata">

**Author:** ![mickaelcaro](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/mickaelcaro/32/4147_2.png) [@mickaelcaro](https://community.sonarsource.com/u/mickaelcaro)\
**Post date:** [December 19, 2022, 1:33pm UTC](https://community.sonarsource.com/t/run-sonarqube-azure-devops-scanner-using-openjdk-17/78724/6 "2022-12-19T13:33:12Z")

</div>

Hi @christopher9

I don’t have out of the box example, but having a bash script before, backing up the current value of JAVA\_HOME

```bash
export JAVA_HOME_BCK=$JAVA_HOME
export JAVA_HOME=/path/to/java

```

then doing the same the other way around after the analysis should work.

```bash
export JAVA_HOME=$JAVA_HOME_BCK

```

Making sure this new env variable is being picked up by the subsequent tasks also would help, sometimes there are issues with it.

HTH,

---

<div class="post-metadata">

**Author:** ![ArminPrieschl](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/arminprieschl/32/17710_2.png) [@ArminPrieschl](https://community.sonarsource.com/u/ArminPrieschl)\
**Post date:** [June 5, 2023, 6:57am UTC](https://community.sonarsource.com/t/run-sonarqube-azure-devops-scanner-using-openjdk-17/78724/8 "2023-06-05T06:57:37Z")

</div>

> [@christopher9](#):
>
> ng OpenJDK 17? For example, can I set the variable

Hi!  
Any news on this topic?  
When do you plan to ship the support for JAVA\_HOME\_17\_X64 ?  
THX

---

<div class="post-metadata">

**Author:** ![mickaelcaro](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/mickaelcaro/32/4147_2.png) [@mickaelcaro](https://community.sonarsource.com/u/mickaelcaro)\
**Post date:** [June 15, 2023, 5:46am UTC](https://community.sonarsource.com/t/run-sonarqube-azure-devops-scanner-using-openjdk-17/78724/9 "2023-06-15T05:46:25Z")

</div>

Hi @ArminPrieschl and @christopher9

I’m happy to share that we released a new version of the extension yesterday that is adding this support.

The Run Code Analysis now has a configurable field to let you choose which variable (or java version) you want to pick up for the analysis.

![Screenshot 2023-06-15 at 07.34.32](https://europe1.discourse-cdn.com/sonarsource/uploads/sonarcommunity/original/3X/5/3/53132c2cc36a566c3309c60e146a0c6ff283f7aa.png)

In your case you may want to use “Use built-in JAVA\_HOME\_17\_X64 (hosted agent)” value.

Hope that helps,  
Mickaël
