2

I am using the following to write a message producer:

  • Maven
  • Java 1.8
  • Ubuntu

My pom.xml file has this entry from http://kafka.apache.org/documentation.html#theproducer

        <dependency>
            <groupId>org.apache.kafka</groupId>
            <artifactId>kafka-clients</artifactId>
            <version>0.8.2.0</version>
        </dependency>

When I issued here is what my HelloWorld.java app looks like:

import kafka.javaapi.producer.Producer;

public class HelloWorld
{
        public static void main(String args[])
        {
                int x = 4;
                System.out.println("hello world");
        }
}

I then compile using Maven.

mvn compile

But I get the following error.

[ERROR] /home/azureuser/test-application/src/main/java/HelloWorld.java:
            [6,30] package kafka.javaapi.producer does not exist

Does anyone know what is missing?

Any help appreciated.

2
  • In your IDE, does it say this package exists in the project? Commented Feb 26, 2015 at 8:16
  • incorrect import : it should be import org.apache.kafka.clients.producer.Producer; Commented Feb 26, 2015 at 8:38

3 Answers 3

1

Based on my search on Maven Central it looks like your defined dependency is wrong.

Sign up to request clarification or add additional context in comments.

Comments

1

Look into your .m2 repository and find the jar (.m2/repository/org/apache/kafka/kafka-clients-0.8.2.0.jar) file, and you will see that the import should be:

import org.apache.kafka.clients.producer.Producer;

Comments

1

I think the correct import should be org.apache.kafka.clients.producer. Check the packages section at the bottom here

1 Comment

Excellent. Thanks. It is the solution.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.