Apache Kafka appends wrong JAVA path
9,606
sudo vi ~/.bashrc
- Edit your java home to below
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64/jre/
export PATH=$PATH:$JAVA_HOME/bin
source ~/.bashrc
- then start Kafka
~/kafka/bin/kafka-server-start.sh ~/kafka/config/server.properties
Related videos on Youtube
Author by
chriskvik
Updated on September 18, 2022Comments
-
chriskvik over 1 year
I have installed the OpenJDK Headless JAVA package on a Ubuntu 16.04 which works fine. My
JAVA_HOME
variable is set to:/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java
But when I'm starting Apache Kafka it tries to load JAVA from the wrong path. It looks like it is appending
/bin/java
to the end of theJAVA_HOME
variable.$ sudo /opt/kafka/kafka_2.11-1.1.0/bin/kafka-server-start.sh /opt/kafka/kafka_2.11-1.1.0/config/server.properties /opt/kafka/kafka_2.11-1.1.0/bin/kafka-run-class.sh: line 271: /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java/bin/java: Not a directory /opt/kafka/kafka_2.11-1.1.0/bin/kafka-run-class.sh: line 271: exec: /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java/bin/java: cannot execute: Not a directory
I tried changing
JAVA_HOME
to just:/usr/lib/jvm/java-8-openjdk-amd64/jre/
But it is still pointing to the same (invalid) java executable.
I then inspected the 271 line in kafka-run-class.sh which says:
exec $JAVA $KAFKA_HEAP_OPTS $KAFKA_JVM_PERFORMANCE_OPTS $KAFKA_GC_LOG_OPTS $KAFKA_JMX_OPTS $KAFKA_LOG4J_OPTS -cp $CLASSPATH $KAFKA_OPTS "$@"
So it looks like it is using the
JAVA
variable, so I try to exportJAVA="/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java"
without any luck.Can anyone explain why this is happening, and how I can solve this?
-
John about 6 yearsSeems Kafka needs JDK and not JRE. See tutorialspoint.com/apache_kafka/…
-
Rico almost 6 yearsI had the same problem an resolved it by setting JAVA_HOME variable.
-