'Why is kafka not creating a topic? - is not a recognized option

I am new to Kafka and trying to create a new topic on my local machine. I am following this https://medium.com/@maftabali2k13/setting-up-a-kafka-cluster-on-ec2-1b37144cb4e

  1. Start zookeeper
bin/zookeeper-server-start.sh -daemon config/zookeeper.properties

Start kafka-server

bin/kafka-server-start.sh -daemon config/server.properties

Create a topic

bin/kafka-topics.sh --create -–bootstrap-server localhost:9092 -–replication-factor 1 -–partitions 1 --topic jerry

but when creating the topic, I am getting the following error


Exception in thread "main" joptsimple.UnrecognizedOptionException: – is not a recognized option
        at joptsimple.OptionException.unrecognizedOption(OptionException.java:108)
        at joptsimple.OptionParser.validateOptionCharacters(OptionParser.java:633)
        at joptsimple.OptionParser.handleShortOptionCluster(OptionParser.java:528)
        at joptsimple.OptionParser.handleShortOptionToken(OptionParser.java:523)
        at joptsimple.OptionParserState$2.handleArgument(OptionParserState.java:59)
        at joptsimple.OptionParser.parse(OptionParser.java:396)
        at kafka.admin.TopicCommand$TopicCommandOptions.<init>(TopicCommand.scala:552)
        at kafka.admin.TopicCommand$.main(TopicCommand.scala:49)
        at kafka.admin.TopicCommand.main(TopicCommand.scala)

I had seen the following Why is kafka not creating a topic? bootstrap-server is not a recognized option But I cant find an answer to my problem here as the error given is different. Is there some stuff that I am missing here?



Solution 1:[1]

I've used your command and had same issue:

bin/kafka-topics.sh --create -–bootstrap-server localhost:9092 -–replication-factor 1 -–partitions 1 --topic jerry

If you look closer to your command you will see, that before options: bootstrap-server, replication-factor and partitions are strange characters.

I think you use copy/paste method and some strange characters were added:

Following command should work: bin/kafka-topics.sh --create --bootstrap-server localhost:9092 --replication-factor 1 --partitions 1 --topic jerry

Best way is to write it by your own :).

Solution 2:[2]

In the latest version kafka_2.12-3.1.0 (2022) after unzipping and setting the properties and logs. keep the Kafka folder on the C drive and always run the command prompt with 'run as administrator'. The .bat file is for windows

Terminal 1

C:\kafka\bin\windows>zookeeper-server-start.bat ..\..\config\zookeeper.properties

Terminal 2

C:\kafka\bin\windows>kafka-server-start.bat ..\..\config\server.properties

Terminal 3

C:\kafka\bin\windows>kafka-topics.bat --create --topic tutorialspedia --bootstrap-server localhost:9092

Created topic tutorialspedia.

To checklist of topic created

C:\kafka\bin\windows>kafka-topics.bat --list --bootstrap-server localhost:9092

tutorialspedia

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 GirishBabuC