According to this answer, I extracted the exe file (I'm windows user) and copied the necessary files. For Elasticsearch, it worked. I set java_home variable in the elasticsearch.bat
set JAVA_HOME=path/to/jdk/file
I tried the same with Logstash. I set the same JAVA_HOME in logstash.bat file and setup.bat, but no it doesn't work with this way.
How to set JAVA_HOME for Logstash without installing Java 8 on the PC?
Yes, I am trying to set my custom JAVA_HOME in logstash.bat file like:
@echo off
setlocal enabledelayedexpansion
set params='%*'
set JAVA_HOME=path\to\custom_jdk_folder\jdk_8u161
...
But I think logstash still works with the JAVA_HOME that it's defined in the System environment variables (It's Windows, yes). Because it prints out as error that Error: Could not find or load main class Files\Java\jre7\lib\ext\QTJava.zip; and the error goes on... C:\Program Files\Java\jre7 is the JAVA_HOME from the System variables.
Instead of that, I need to run Logstash with the Java here: path\to\custom_jdk_folder\jdk_8u161
What happens if you set a custom JAVA_HOME environment variable (rather than trying to edit the logstash.bat file)? Also, is there any reason not to simply install JDK8 system wide on this system?
I don't have admin rights on the PC, so I cannot set new System environment variable and also install JDK8. I have JDK7 installed and JAVA_HOME system variable for JDK7.
So, using java.exe from a JDK extracted folder is the only option for me, I guess.
From my reading of the batch files, the JAVA_HOME seems to be mainly used to derive the JAVA variable. Try if directly setting JAVA to the full path to java.exe in your modified logstash.bat works:
I tried many other things.. With double quotes, without double quotes, set JAVA_HOME in logstash.bat, set JAVA directly to the java.exe in setup.bat, mix them, change them, try other combinations etc but no. None of them works like in the Elasticsearch. I just set my custom JAVA_HOME in elasticsearch.bat and voiala, it just works!
It seems like Logstash never detect my JAVA_HOME, JAVA variable at all. I want to force it to use my Java8, not the Java7 installed on the PC.
Simplify this, instead of modifying the original logstash.bat file add another logstash.bat file in a different folder, add JAVA_HOME at the start of that bat file, then call the real logstash.bat file. That way you can switch between logstash and java versions easily by just modifying your custom logstash.bat file
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.