# Elasticsearch can't find Java

**URL:** <https://discuss.elastic.co/t/elasticsearch-cant-find-java/108821>\
**Category:** Elasticsearch\
**Created:** [November 23, 2017, 5:25am UTC](https://discuss.elastic.co/t/elasticsearch-cant-find-java/108821 "2017-11-23T05:25:55Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![tkzv](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tkzv/32/57319_2.png) [@tkzv](https://discuss.elastic.co/u/tkzv)\
**Post date:** [November 23, 2017, 5:25am UTC](https://discuss.elastic.co/t/elasticsearch-cant-find-java/108821/1 "2017-11-23T05:25:55Z")

</div>

I tried installing Elastic Stack to a clean Windows 7 x64 and couldn't run it because it can't see Java. Both PATH and JAVA\_HOME are set. The user is an admin. Same result with and without "Run as admin" command. Same result for JRE 8 and JDK 9. (Right now I only have 9 and pieces of 6 that came with Oracle.)

How to make Elastic programs see Java?

```
C:\Elastic\elasticsearch\bin>elasticsearch
could not find java; set JAVA_HOME or ensure java is in PATH

C:\Elastic\elasticsearch\bin>echo %path%
C:\ProgramData\Oracle\Java\javapath_target_9842531;C:\ProgramData\Oracle\Java\javapath_target_5202453;C:\app\admin\product\11.1.0\db_1\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;c:\Program Files (x86)\Microsoft SQL Server\90\Tools\binn\

C:\Elastic\elasticsearch\bin>echo %java_home%
C:\ProgramData\Oracle\Java

C:\Elastic\elasticsearch\bin>java -version
java version "9.0.1"
Java(TM) SE Runtime Environment (build 9.0.1+11)
Java HotSpot(TM) 64-Bit Server VM (build 9.0.1+11, mixed mode)

C:\Elastic\elasticsearch\bin>dir %java_home%
 Volume in drive C has no label.
 Volume Serial Number is 64EE-6DE2

 Directory of C:\ProgramData\Oracle\Java

11/22/2017 08:51 PM <DIR> .
11/22/2017 08:51 PM <DIR> ..
11/22/2017 08:45 PM <DIR> .oracle_jre_usage
11/22/2017 08:51 PM <DIR> installcache_x64
11/22/2017 08:44 PM 14 java.settings.cfg
11/22/2017 08:51 PM <JUNCTION> javapath [C:\ProgramData\Oracle\Java\java
path_target_9842531]
11/22/2017 08:51 PM <DIR> javapath_target_9842531
               1 File(s) 14 bytes
               6 Dir(s) 13,177,876,480 bytes free

C:\Elastic\elasticsearch\bin>dir %java_home%\javapath
 Volume in drive C has no label.
 Volume Serial Number is 64EE-6DE2

 Directory of C:\ProgramData\Oracle\Java\javapath

11/22/2017 08:51 PM <DIR> .
11/22/2017 08:51 PM <DIR> ..
11/22/2017 08:45 PM 231,488 java.exe
11/22/2017 08:45 PM 232,000 javaw.exe
11/22/2017 08:45 PM 333,888 javaws.exe
               3 File(s) 797,376 bytes
               2 Dir(s) 13,177,876,480 bytes free

```

Answer: Install JDK 8 and set  
`JAVA_HOME=C:\Program Files\Java\jdk1.8.0_152`

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [November 23, 2017, 5:28am UTC](https://discuss.elastic.co/t/elasticsearch-cant-find-java/108821/2 "2017-11-23T05:28:34Z")

</div>

We don't support Windows 7 or Java 9 sorry to say.

---

<div class="post-metadata">

**Author:** ![tkzv](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tkzv/32/57319_2.png) [@tkzv](https://discuss.elastic.co/u/tkzv)\
**Post date:** [November 23, 2017, 5:30am UTC](https://discuss.elastic.co/t/elasticsearch-cant-find-java/108821/3 "2017-11-23T05:30:17Z")

</div>

> [@warkolm](#):
>
> We don't support Windows 7 or Java 9 sorry to say.

I got exactly the same result with JRE 8.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [November 23, 2017, 6:25am UTC](https://discuss.elastic.co/t/elasticsearch-cant-find-java/108821/4 "2017-11-23T06:25:37Z")

</div>

Did you define java\_home or JAVA\_HOME?

---

<div class="post-metadata">

**Author:** ![tkzv](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tkzv/32/57319_2.png) [@tkzv](https://discuss.elastic.co/u/tkzv)\
**Post date:** [November 23, 2017, 6:40am UTC](https://discuss.elastic.co/t/elasticsearch-cant-find-java/108821/5 "2017-11-23T06:40:12Z")

</div>

> [@dadoonet](#):
>
> Did you define java\_home or JAVA\_HOME?

`JAVA_HOME=C:\ProgramData\Oracle\Java`  
In capital letters, if you ask about that.  
It's in the system settings.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [November 23, 2017, 7:07am UTC](https://discuss.elastic.co/t/elasticsearch-cant-find-java/108821/6 "2017-11-23T07:07:28Z")

</div>

Your Java installation looks strange to me.

Inside JAVA\_HOME you should see something like:

```auto
-rwxrwxr-x 1 root wheel 5097973 26 jui 23:04 javafx-src.zip
-rwxrwxr-x 1 root wheel 63933 26 jui 23:04 THIRDPARTYLICENSEREADME-JAVAFX.txt
-rw-rw-r-- 1 root wheel 3244 22 jul 08:27 COPYRIGHT
drwxrwxr-x 9 root wheel 288 22 jul 08:27 db
drwxrwxr-x 9 root wheel 288 22 jul 08:27 include
-rw-rw-r-- 1 root wheel 529 22 jul 08:27 release
drwxrwxr-x 5 root wheel 160 22 jul 08:27 man
-rw-rw-r-- 1 root wheel 159 22 jul 08:27 README.html
-rw-rw-r-- 1 root wheel 40 22 jul 08:27 LICENSE
-rw-rw-r-- 1 root wheel 21252173 22 jul 08:27 src.zip
-rw-rw-r-- 1 root wheel 145180 22 jul 08:27 THIRDPARTYLICENSEREADME.txt
drwxrwxr-x 10 root wheel 320 22 jul 08:29 jre
drwxrwxr-x 14 root wheel 448 22 jul 08:29 lib
drwxrwxr-x 46 root wheel 1472 22 jul 08:31 bin
drwxr-xr-x 3 root wheel 96 11 aoû 21:05 bundle

```

Specifically the `bin` dir.

Does not look like this here.

---

<div class="post-metadata">

**Author:** ![tkzv](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tkzv/32/57319_2.png) [@tkzv](https://discuss.elastic.co/u/tkzv)\
**Post date:** [November 23, 2017, 7:15am UTC](https://discuss.elastic.co/t/elasticsearch-cant-find-java/108821/7 "2017-11-23T07:15:53Z")

</div>

java.exe is available in C:\Program files\ as a real file and in C:\ProgramData\ as a link. Some earlier post suggested pointing JAVA\_HOME to C:\ProgramData\ . I tried both with the same results. Haven't tried it with JDK 8, though.

Setting JAVA\_HOME=C:\Program Files\Java\jdk1.8.0\_152 solved the problem. Thanks.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [December 21, 2017, 7:16am UTC](https://discuss.elastic.co/t/elasticsearch-cant-find-java/108821/8 "2017-12-21T07:16:01Z")

</div>

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