Elasticsearch can't find Java

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

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

I got exactly the same result with JRE 8.

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.

Your Java installation looks strange to me.

Inside JAVA_HOME you should see something like:

-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.

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.

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