Cannot locate Java installation, specified by JAVA_HOME: C:\ProgramData\Oracle\Java\javapath\java.exe
- Dominant language
- Java
- Stars
- 14.9k
- Forks
- 3.5k
- Avg merge
- 19h 14m
- Merged PRs (30d)
- 63
Description
- Version: logstash-5.4.0
- Operating System: Windows Server 2012 R2
- **JRE Version: 1.8.0_141**
Logstash fails to start when JAVA_HOME is not set.
Here is the error I got:
Cannot locate Java installation, specified by JAVA_HOME:
C:\ProgramData\Oracle\Java\javapath\java.exe
The problem seems to be in retrieving the folder from the path to java.exe (from PATH) in setup.bat, the script assumes that the path should be like this: %JAVA_HOME%\bin\java.exe
In case of JRE 1.8.x it's no longer the case (apparently, I have no official links to confirm, but I did a clean install and it looks like it's like this at least for 1.8.0_141). The installer now creates some symbolic links and adds them to PATH, it was "C:\ProgramData\Oracle\Java\javapath\java.exe" in my case (no subfolder "bin").
Note that the installer does not add JAVA_HOME variable (nor updates existing value, when JRE is updated), so retrieving it from path to java.exe seems reasonable, but it looks like it's broken in never versions of JRE.
I did a quick experiment of removing the whole JAVA_HOME retrieval code from setup.bat and removing JAVA_HOME env variable completely and it looks like logstash in this case works fine. Does it mean that Oracle along with the change in folder structure changed requirements for JAVA_HOME? Maybe setup.bat also should assume that undefined JAVA_HOME is correct?
My workaround: set up JAVA_HOME manually, but it's a pain, because whenever JRE is updated, logstash stops working until I change the JAVA_HOME manually (JRE is updated automatically).
This issue seems to be related, btw:
[Logstash aborts at startup with "Java\java_1.8.0 unexpected at this time." #5357](https://github.com/elastic/logstash/issues/5357)
Contributor guide
Assessment
This issue has not been assessed yet.