Kafka Unrecognized VM option 'PrintGCDateStamps'

So I found an answer and wanted to post it in case anyone else had this problem. In the kafka/bin/kafka-run-class.sh at the very bottom there is a part where it says

exec $JAVA $KAFKA_HEAP_OPTS $KAFKA_JVM_PERFORMANCE_OPTS $KAFKA_GC_LOG_OPTS $KAFKA_JMX_OPTS $KAFKA_LOG4J_OPTS -cp $CLASSPATH $KAFKA_OPTS "$@"

Delete the $KAFKA_GC_LOG_OPTS option. Might be a hack, but at least it gets the kafka zookeeper server to start!


Actually, Kafka works fine with newer versions of Java. I had the same problem, and found an error in the kafka/bin/kafka-run-class.sh script, where the Java version was incorrectly parsed.

This line grabs too much of the version string:

JAVA_MAJOR_VERSION=$($JAVA -version 2>&1 | sed -E -n 's/.* version "([^.-]*).*"/\1/p')

This makes the if [[ "$JAVA_MAJOR_VERSION" -ge "9" ]] condition fail to identify the correct Java version, and adds some unsupported GC options.

Changing the line above to this solved my problem:

JAVA_MAJOR_VERSION=$($JAVA -version 2>&1 | sed -E -n 's/.* version "([^.-]*).*/\1/p')

I have reported this as an issue with Kafka. The issue can be found here: https://issues.apache.org/jira/browse/KAFKA-6855

EDIT: There is a committed fix for this: https://github.com/apache/kafka/commit/e9f86c3085fa8b65e77072389e0dd147b744f117


Like the other answers -- I got this to work on Java 9. Had to make the following changes:

  1. Edit the file bin/kafka-run-class.sh

  2. Near the end of the file (around line 248) find the following block:

if [ "x$GC_LOG_ENABLED" = "xtrue" ]; then GC_LOG_FILE_NAME=$DAEMON_NAME$GC_FILE_SUFFIX KAFKA_GC_LOG_OPTS="-Xloggc:$LOG_DIR/$GC_LOG_FILE_NAME -verbose:gc -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCTimeStamps " fi

  1. Remove the 2 flags : -XX:+PrintGCDateStamps -XX:+PrintGCTimeStamps and save the file.

  2. Kafka should start okay on Java 9


Same issue on Ubuntu 16.04 with oracle jdk 9 installed, I have also tried openjdk 1.9 and got the same error. But when I try other version jdk, I found that oracle jdk 8 and openjdk 1.8 are both ok.

So just check out what version of java you're using, maybe you can install or switch to other version of jdk by:

update-alternatives --display java
update-alternatives --config java
java -version