11

I have ELK installed on a VM in my laptop.Elasticsearch is up and running.

./bin/logstash -f logstash-filter.conf gives me the below error Could not find any executable java binary. Please install java in your PATH or set JAVA_HOME.

I tried setting up JAVA_HOME and $ PATH, still the issue is persistent. Am I missing something?

 which java
/usr/bin/java


java -version
java version "1.7.0_79"
OpenJDK Runtime Environment (IcedTea 2.5.5) (7u79-2.5.5-0ubuntu0.14.04.2)
OpenJDK 64-Bit Server VM (build 24.79-b02, mixed mode)

echo $JAVA_HOME
/usr/local/java/jdk1.8.0_45

echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/divija/bin:/usr/local/java/jdk1.8.0_45/bin

logstash-filter.conf

input { stdin { } }

filter {
  grok {
    match => { "message" => "%{COMBINEDAPACHELOG}" }
  }
  date {
    match => [ "timestamp" , "dd/MMM/yyyy:HH:mm:ss Z" ]
  }
}

output {
  elasticsearch { host => localhost 
    index=>"myindex"
}
  stdout { codec => rubydebug }`enter code here`
}

2 Answers 2

20

I had to

export JAVACMD=`which java`

to make this work.

Sign up to request clarification or add additional context in comments.

Comments

1

I know, it's an old thread, but I was also having the same problem and was doing a very silly thing.

I had updated my $JAVA_HOME var in /etc/environment but was not reloading the file because of which it was not taking effect, and running source /etc/environment solved my problem.

4 Comments

I don't get it, I am also facing the same issue. I tried setting javacmd and running ./system-install from the /usr/share/logstash/bin. Im still facing the JAVA error. could not find java; set JAVA_HOME or ensure java is in PATH @raghav,@Raghav Garg
@SPishere, can you please share your output for which java, java -version, echo $JAVACMD, echo $JAVA_HOME, echo $PATH.
They all are pointing to the right path, However i was able to fix it by adding JAVA_HOME=path/to/jdk in the startup.options.
@SPishere, so now your logstash is working, right? After setting JAVA_HOME.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.