error: package org.apache.kafka.clients.producer does not

天大地大妈咪最大 提交于 2019-12-12 11:15:17

问题


I am new to kafka. When I run this command

javac -cp "C:\kafka\kafka_2.11-0.10.2.0\libs\kafka-clients-0.10.2.0.jar" *.java

I get an error message

error: package org.apache.kafka.clients.producer does not exist


回答1:


In addition to the answer of @Abhishek:-

First download the Kafka-clients library dependencies from [https://mvnrepository.com/artifact/org.apache.kafka/kafka-clients]

Copy the org folder and paste it in the lib folder of our main Kafka directory.

Then Run the above two given commands

Also It can be run by simple commands :-

javac -cp libs *.java

java -cp libs SimpleProducer *topicname*



回答2:


The following command works well

javac -classpath ".;C:\kafka\kafka_2.11-0.10.2.0\libs\kafka-clients-0.10.2.0.jar;" *.java

But actually we should use the following to compile

javac -classpath ".;C:\kafka\kafka_2.11-0.10.2.0\libs\*;" *.java

and to run the class file this

java -classpath ".;C:\kafka\kafka_2.11-0.10.2.0\libs\*;" SimpleProducer topicname


来源:https://stackoverflow.com/questions/43340844/error-package-org-apache-kafka-clients-producer-does-not

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!