Could not find 'java' executable in JAVA_HOME


I am encountering the below issue on CentOS Linux release 7.9.2009 (Core)

java -version

openjdk version “” 2020-11-04 LTS
OpenJDK Runtime Environment 18.9 (build
OpenJDK 64-Bit Server VM 18.9 (build, mixed mode, sharing)
(reverse-i-search)`son’: stat /opt/scannerdir/^Cnar-scanner-




Could not find ‘java’ executable in JAVA_HOME or PATH.

Any clue? Thanks in advance. I look forward to hearing from you. Please let me know if you need any additional information.

Best Regards,


Hi Kaushal, welcome to the SonarSource Community!

It appears based on your pasted output that you downloaded the version of sonar-scanner that includes an embedded JRE yet you also have a separate JDK already installed. In this case, you may wish to use the sonar-scanner zip install that does not bundle another JRE.

Yet still, it should have succeeded. How exactly did you invoke sonar-scanner and from which directory? Did you add its bin directory to your PATH first as our docs suggest? Is it being invoked directly or within another shell or script of some kind?

+1 on this.

I have the same issue on Ubuntu 18.04.5 LTS

java -version
openjdk version “1.8.0_282”
OpenJDK Runtime Environment (build 1.8.0_282-8u282-b08-0ubuntu1~18.04-b08)
OpenJDK 64-Bit Server VM (build 25.282-b08, mixed mode)


“Could not find ‘java’ executable in JAVA_HOME or PATH.”

I’m invoking sonar-scanner directly from the top level dir of my repo, and I have added the sonar-scanner bin dir to my PATH. No luck.

Any help would be great.

Turns out the error message is misleading. The real problem is the java executable that is included in sonar-scanner-#.#.#.####-linux/jre/bin/ needs execute permissions set. After running

chmod 755 .../sonar-scanner-#.#.#.####-linux/jre/bin/java

sonar-scanner was able to scan.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.