Could not find 'java' executable in JAVA_HOME

Hi,

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

java -version

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

echo $JAVA_HOME

/usr/lib/jvm/java-11-openjdk-11.0.9.11-2.el7_9.x86_64

sonar-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,

Kaushal

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?