1

I am starting to learn Kafka. I managed to run zookeeper and kafka successfully. I am using Windows10 and my kafka version is 2_12-2.5.0. My question is that when I try to create a topic from cmd using the below command:

kafka-topics.bat --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic firstTopic`

I get the error:

The syntax of the command is incorrect.

I know that the command I wrote is correct and the issue is the command inside the .bat file as I changed the command inside the kafka-topics.bat, the error changes. However I could not manage to run it. This is the content of kafka-topics.bat:

"%~dp0kafka-run-class.bat" kafka.admin.TopicCommand %* 

I also tried to run kafka-topics.sh file instead of batch, but that gives a different error opening git bash, that is:

Error:Could not find or load main class kafka.admin.topicCommand 

I also got rid of the space in "Program Files" while writing the path, so I don't think that is the reason of this error.

I got stuck and its hard to understand these errors as I am new. Can you please help?

theSK
  • 11
  • 3
  • Error you got might be different but maybe this will help, Please check it out- https://stackoverflow.com/questions/25037263/apache-kafka-error-on-windows-couldnot-find-or-load-main-class-quorumpeermain – rootkonda Jul 11 '20 at 22:48
  • I suppose \` at end of first command line is added by mistake on writing the question. – Mofi Jul 13 '20 at 08:48
  • I suggest to change the current working directory with `cd /D "directory path"` to the directory containing `kafka-topics.bat` and `kafka-run-class.bat`. The path of the batch files can be seen on running `where kafka-topics.bat`. – Mofi Jul 13 '20 at 08:49
  • Not an answer, but I encountered the same problem and decided to use the WSL bash to run the Linux scripts, which works well. (Using openjdk-11). I had to edit my hostfile [as described here](https://boristyukin.com/connecting-to-kafka-on-virtualbox-from-windows/) though. – Seldon Jul 13 '20 at 19:49
  • 1
    I solved the problem partly. I changed the directory to C:\ , don't think this was the answer, and I downloaded kafka binary version instead of source. .bat files work but I still encounter the same problem for .sh files. Good thing that I never intended to use .sh – theSK Jul 14 '20 at 08:12

2 Answers2

0

in my case it worked only when I moved Kafka folder to C: partition without any space in path for example C:\Kafka_sources and I used the below command to create a topic

kafka-topics.bat --create --topic test --zookeeper localhost:2181 --partitions 1 --replication-factor 1
0

in my case:

  • i removed the quotation marks in .properties for directories
  • use forward slashes in .properties for directories
  • i removed the dot-version numbers in directory path (don't know if that was deciding)
  • but start with point and backlashes .\bin\windows\kafka-server-start.bat .\config\server.properties)
  • d:\ is possible !