Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 992
Abhishek Bhattacharjee Avatar asked Apr 11 '17 08:04

Abhishek Bhattacharjee


2 Answers

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*
like image 109
Nitin Bisht Avatar answered Nov 12 '22 03:11

Nitin Bisht


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
like image 43
Abhishek Bhattacharjee Avatar answered Nov 12 '22 02:11

Abhishek Bhattacharjee