# Azure DevOps complaining that JAVA\_HOME is not set

**URL:** <https://community.sonarsource.com/t/azure-devops-complaining-that-java-home-is-not-set/17195>\
**Category:** SonarQube Cloud\
**Created:** [November 28, 2019, 3:12pm UTC](https://community.sonarsource.com/t/azure-devops-complaining-that-java-home-is-not-set/17195 "2019-11-28T15:12:54Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![gmoulin](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/gmoulin/32/7913_2.png) [@gmoulin](https://community.sonarsource.com/u/gmoulin)\
**Post date:** [November 28, 2019, 3:12pm UTC](https://community.sonarsource.com/t/azure-devops-complaining-that-java-home-is-not-set/17195/1 "2019-11-28T15:12:54Z")

</div>

Build fails while executing “Run Code Analysis”  
Pool: Azure Pipelines  
Agent: Hosted Agent

# Starting: Run Code Analysis

Task : Run Code Analysis  
Description : Run scanner and upload the results to the SonarCloud server.  
Version : 1.9.0  
Author : sonarsource  
Help : This task is not needed for Maven and Gradle projects since the scanner should be run as part of the build.

# [More Information](http://redirect.sonarsource.com/doc/install-configure-scanner-tfs-ts.html)

```auto
[command]D:\_work\_tasks\SonarCloudPrepare_14d9cde6-c1da-4d55-aa01-2965cd301255\1.9.0\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe end
SonarScanner for MSBuild 4.7.1
Using the .NET Framework version of the Scanner for MSBuild
Post-processing started.

Calling the SonarQube Scanner...

ERROR: JAVA_HOME not found in your environment, and no Java
       executable present in the PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation, or add "java.exe" to the PATH

##[error]The SonarQube Scanner did not complete successfully
The SonarQube Scanner did not complete successfully
##[error]10:03:46.845 Post-processing failed. Exit code: 1
10:03:46.845 Post-processing failed. Exit code: 1
##[error]The process 'D:\_work\_tasks\SonarCloudPrepare_14d9cde6-c1da-4d55-aa01-2965cd301255\1.9.0\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe' failed with exit code 1
##[section]Finishing: Run Code Analysis

```

---

<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:** [November 29, 2019, 9:17am UTC](https://community.sonarsource.com/t/azure-devops-complaining-that-java-home-is-not-set/17195/3 "2019-11-29T09:17:25Z")

</div>

Hi @gmoulin and welcome to the community !

Are you sure that the logs comes from an MS-Hosted agent ? If yes, can you give me the image name ? Given the paths, i would rather say that it comes from a self-hosted one.

Message is pretty clear then, the JAVA\_HOME is either not set or not accessible from the user that runs the pipeline. Can you check by adding a powershell script with the corresponding inline script :

```auto
Write-Host "JAVA_HOME : $env:JAVA_HOME"
& java --version

```

And see the result ?

Thanks.

Mickaël

---

<div class="post-metadata">

**Author:** ![gmoulin](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/gmoulin/32/7913_2.png) [@gmoulin](https://community.sonarsource.com/u/gmoulin)\
**Post date:** [November 29, 2019, 9:33am UTC](https://community.sonarsource.com/t/azure-devops-complaining-that-java-home-is-not-set/17195/4 "2019-11-29T09:33:28Z")

</div>

Hi @mickaelcaro.

This had been executed directly in the cloud in an Azure DevOps pipieline, we don"t have an on-premise build server.

Regards

---

<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:** [November 29, 2019, 9:37am UTC](https://community.sonarsource.com/t/azure-devops-complaining-that-java-home-is-not-set/17195/5 "2019-11-29T09:37:39Z")

</div>

Which image version are you using ?

---

<div class="post-metadata">

**Author:** ![gmoulin](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/gmoulin/32/7913_2.png) [@gmoulin](https://community.sonarsource.com/u/gmoulin)\
**Post date:** [November 29, 2019, 9:46am UTC](https://community.sonarsource.com/t/azure-devops-complaining-that-java-home-is-not-set/17195/6 "2019-11-29T09:46:55Z")

</div>

Was using **win1803**. It works with **windows-2019**.  
Thanks @mickaelcaro

---

<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:** [November 29, 2019, 9:48am UTC](https://community.sonarsource.com/t/azure-devops-complaining-that-java-home-is-not-set/17195/7 "2019-11-29T09:48:43Z")

</div>

Perfect ! Don’t know why they didn’t set JAVA\_HOME in this particular flavor, but glad that it works.

Thank you.
