Kafka Unrecognized option PrintGCDateStamps
StackOverflow user Mitchell Tracy was experiencing problems getting Kafka to start. The error message Unrecognized VM option 'PrintGCDateStamps'
suggested the wrong version of Java was running. The PrintGCDateStamps
option was removed in Java 9, so I assumed the startup script either explicitly required version 8 (or earlier) to run, or had some error detecting the version correctly.
It turned out to be the latter. I had recently experienced the same problem, and solved it by first looking through the scripts that started Kafka, where I discovered an error in the kafka/bin/kafka-run-class.sh
script, so that the Java version was parsed incorrectly.
The following line extracts too much of the version string:
JAVA_MAJOR_VERSION=$($JAVA -version 2>&1 | sed -E -n 's/.* version "([^.-]*).*"/\1/p')
This made the if [[ "$JAVA_MAJOR_VERSION" -ge "9" ]]
codition fail to identify the correct Java version, and that's why some unsupported GC options were added.
To solve the problem, I replaced the line above with the following:
JAVA_MAJOR_VERSION=$($JAVA -version 2>&1 | sed -E -n 's/.* version "([^.-]*).*/\1/p')
I reported the issue with Kafka: KAFKA-6855, and they eventually fixed it in this pull request: PR #4895.