I've just installed Kafka following tutorial. It doesn't start because of sh
script error:
$ sudo kafka-server-start.sh /etc/kafka.properties /opt/Kafka/kafka_2.12-1.1.0/bin/kafka-run-class.sh: line 252: [[: 10 2018-04-17: syntax error in expression (error token is "2018-04-17") [0.000s][warning][gc] -Xloggc is deprecated. Will use -Xlog:gc:/opt/Kafka/kafka_2.12-1.1.0/bin/../logs/kafkaServer-gc.log instead. Unrecognized VM option 'PrintGCDateStamps' Error: Could not create the Java Virtual Machine. Error: A fatal exception has occurred. Program will exit.
checking line 252:
if [[ "$JAVA_MAJOR_VERSION" -ge "9" ]] ; then
I've added echo
to get more info:
JAVA_MAJOR_VERSION=$($JAVA -version 2>&1 | sed -E -n 's/.* version "([^.-]*).*"/\1/p') echo "JAVA_MAJOR_VERSION: $JAVA_MAJOR_VERSION" if [[ "$JAVA_MAJOR_VERSION" -ge "9" ]] ; then
output is changed with:
JAVA_MAJOR_VERSION: 10 2018-04-17
my java:
$ java -version openjdk version "10.0.1" 2018-04-17
Question
How I should change JAVA_MAJOR_VERSION=$($JAVA -version 2>&1 | sed -E -n 's/.* version "([^.-]*).*"/\1/p')
to fix my Kafka starter?
openjdk version "1.8.0_171"
. Notably, without a date after the version number in the output.| cut -d' ' -f1
after the sed command. Others can magic sed itself. Interesting that openjdk added additional information to the version line. As @DopeGhoti noted, 1.8 doesn't have the date on it. The release of Java 10, though, was early this year, so I'd expect some distributions to start picking it up.