# Could not find 'java' executable in JAVA\_HOME

**URL:** <https://community.sonarsource.com/t/could-not-find-java-executable-in-java-home/36504>\
**Category:** SonarQube Server / Community Build\
**Tags:** java, scanner\
**Created:** [January 4, 2021, 6:07pm UTC](https://community.sonarsource.com/t/could-not-find-java-executable-in-java-home/36504 "2021-01-04T18:07:45Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![kaushalshriyan](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/kaushalshriyan/32/17928_2.png) [@kaushalshriyan](https://community.sonarsource.com/u/kaushalshriyan)\
**Post date:** [January 4, 2021, 6:07pm UTC](https://community.sonarsource.com/t/could-not-find-java-executable-in-java-home/36504/1 "2021-01-04T18:07:45Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Jeff\_Zapotoczny](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/jeff_zapotoczny/32/2816_2.png) [@Jeff\_Zapotoczny](https://community.sonarsource.com/u/Jeff_Zapotoczny)\
**Post date:** [January 4, 2021, 9:08pm UTC](https://community.sonarsource.com/t/could-not-find-java-executable-in-java-home/36504/2 "2021-01-04T21:08:20Z")

</div>

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](https://docs.sonarqube.org/latest/analysis/scan/sonarscanner/)? Is it being invoked directly or within another shell or script of some kind?

---

<div class="post-metadata">

**Author:** ![rennerg](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/rennerg/32/21157_2.png) [@rennerg](https://community.sonarsource.com/u/rennerg)\
**Post date:** [April 12, 2021, 11:27pm UTC](https://community.sonarsource.com/t/could-not-find-java-executable-in-java-home/36504/3 "2021-04-12T23:27:55Z")

</div>

+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)

**echo $JAVA\_HOME**  
/usr/local/java/jre1.8.0\_281/bin

**sonar-scanner**  
“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.  
Thanks

---

<div class="post-metadata">

**Author:** ![rennerg](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/rennerg/32/21157_2.png) [@rennerg](https://community.sonarsource.com/u/rennerg)\
**Post date:** [April 13, 2021, 2:16pm UTC](https://community.sonarsource.com/t/could-not-find-java-executable-in-java-home/36504/4 "2021-04-13T14:16:19Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/system/32/31083_2.png) [@system](https://community.sonarsource.com/u/system)\
**Post date:** [April 20, 2021, 2:17pm UTC](https://community.sonarsource.com/t/could-not-find-java-executable-in-java-home/36504/5 "2021-04-20T14:17:18Z")

</div>

Closed on April 20, 2021, 2:17pm UTC

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