Reputation: 4791
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.
Upvotes: 6
Views: 14028
Reputation: 6620
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>
Upvotes: 3
Reputation: 34109
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
Upvotes: 0
Reputation: 36
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
Upvotes: 1
Reputation: 1474
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
Upvotes: 1
Reputation: 168
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:
Manage Jenkins
-> Global Tool Configuration
JDK installations...
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
Upvotes: 0
Reputation: 21
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)"
Upvotes: 0