Calling the SonarScanner CLI., Could not find 'java' executable in JAVA_HOME or PATH. for DotNet

  1. install dotnet scannerdotnet tool install --global dotnet-sonarscanner --version 5.6.0

dotnet sonarscanner begin and dotnet build commands are running fine.
but for dotnet sonarscanner end /d:sonar.login=$Token command, it gives error as "

**Calling the SonarScanner CLI...
16:09:31   Could not find 'java' executable in JAVA_HOME or PATH.
16:09:32   Process exited with code 1**

I tried setting JAVA_HOME also ( with and without bin in path), but it didn’t work.

export JAVA_HOME=/usr/lib/jvm/jre-openjdk
export PATH="$JAVA_HOME/bin:${PATH}"
export PATH="$PATH:/root/.dotnet/tools"
echo $PATH


ls -lrt /root/.dotnet/tools/
-rwxr-xr-x 1 root root 142840 Jun 14 11:27 /root/.dotnet/tools/dotnet-sonarscanner

I read in posts to change the permission of jre in sonar, but I used “dotnet tool install --global dotnet-sonarscanner --version 5.6.0” to install sonarscanner, so don’t know which location I should go and change the permissions.

Tried this also-
dotnet tool install dotnet-sonarscanner --version 5.6.0 --tool-path /usr/local/bin
dotnet tool install Java.OpenJDK --version 11.0.1-beta001 --tool-path /usr/local/bin

but still same error.

Hi,

Welcome to the community!

When I look at the command line log you’ve pasted, a few things (eventually) occur to me:

When you echo $PATH, you get a blank line back (unless you redacted the value?). So your attempt to add to path is clearing it out instead. … I wonder what effect those quotes are having in your assignment…

Also, if you’re doing this on the command line, you’re doing it for your session & not for the session your build is running in.

 
HTH,
Ann