Jenkins Sonarqube Plugin: JAVA_HOME exists but does not point to a valid Java home
Asked Answered
I

8

6

I am trying to set up the Sonarqube for my project, but when I start to generate a build, I get the following error:

ERROR: JAVA_HOME exists but does not point to a valid Java home
   folder. No "\bin\java.exe" file can be found there.

The SonarQube Scanner did not complete successfully

I check some docs but none of them helps. For the JAVA_HOME environment variable, I point it to be C:\Program Files (x86)\Java\jdk1.8.0_111 I also double check it by using powershell java -version command. It also gives me the same answer: java version "1.8.0_111" . Anyone knows how to solve the problem?

Thanks.

Ils answered 16/12, 2016 at 20:25 Comment(1)
Did you check that java,exe exists? Did you check the access rights?Highpitched
H
3

You can edit:

C:\Users\HOME_FOLDER\.jenkins\tools\hudson.plugins.sonar.SonarRunnerInstallation\SonarQubeScanner\bin>notepad sonar-scanner.bat

and put following:

SET JAVA_HOME=< JDK Path>

Hew answered 1/2, 2017 at 16:28 Comment(0)
M
1

if EXIST in the sonar-scanner.bat fails because there is a space in the path, so the solution is to set the JAVA_HOME to a value without spaces e.g. using the short name of the "Program Files" SET JAVA_HOME= C:\Progra~1\Java\jre9

Mild answered 7/11, 2018 at 16:31 Comment(0)
W
1

I encountered the same error. The issue was with sonar-scanner.bat referencing wrong %JAVA_HOME% path.
In the sonar-scanner.bat the variable "use_embedded_jre" is set to true and immediately the validation is done for the PATH.

@REM ==== START VALIDATION ====
@REM *** JAVA EXEC VALIDATION ***

set use_embedded_jre=true
if "%use_embedded_jre%" == "true" (
  set "JAVA_HOME=%SONAR_SCANNER_HOME%\jre"
)

Set the variable value to "false", the issue will be fixed.

set use_embedded_jre=false
Weaks answered 25/6, 2019 at 13:35 Comment(0)
H
0

Ensure that JAVA_HOME is pointing JDK .

Henka answered 19/12, 2016 at 7:9 Comment(0)
S
0

Please try to reinstall the java 8. Setup JAVA_HOME again then It will work. This problem might be because space between "Program Files (x86)"

Servia answered 19/12, 2016 at 16:46 Comment(0)
A
0

I had the same problem and struggled with it for a while. After modifying sonar-scanner.bat a bit I found out that during execution of Sonarqube the %JAVA_HOME% was completely different from the one I configured in my environment variables. Turned out I had hardcoded JDK installations in my Global Tool Configuration inside Jenkins.

My solution:

  1. Open your Jenkins, go to Manage Jenkins -> Global Tool Configuration
  2. Click JDK installations...
  3. Make sure JAVA_HOME parameter is empty or just click Delete JDK

In this case Jenkins will use %JAVA_HOME% variable it finds during the execution and it's just the one you configured in your environment variables. Worked for me

Aiguillette answered 7/8, 2018 at 22:36 Comment(0)
P
0

You should restart your machine after java installation.

Providence answered 26/6, 2019 at 11:39 Comment(0)
T
0

I was having the same issue. On my machine JRE was located at C:\Program Files (x86)\Jenkins\jre. So I appended System's PATH Environment Variable with C:\Program Files (x86)\Jenkins\jre\bin;

It worked.

Do not forget to restart Jenkins service from Windows Services

Telugu answered 29/10, 2020 at 19:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.