I am getting a NoClassDefFoundError when I try to compile and run the Producer example that comes with Kafka. I want to know how to resolve the error discussed below?
Caveat: I am a C++/C# programmer who is Linux literate and starting to learn Java. I can follow instructions, but may well ask for some clarification along the way.
I have a VM sandbox from Hortonworks that is running a Red Hat appliance. On it I have a working kafka server and by following this tutorial I am able to get the desired Producer posting messages to the server.
Now I want to get down to writing my own code, but first I decided to make sure I can compile the example files that Kafka came with After a day of trial and error I just cannot seem to get this going.
here is what I am doing:
I am going to the directory where the example files are located and typing:
javac -cp $KCORE:$KCLIENT:$SCORE:. ./*.java
$KCORE:$KCLIENT:$SCORE resolve to the jars for the kafka core, kafka-client, and scala libraries respectively. everything returns just fine with no errors and places all the class files in the current directory; however, when I follow up with
javac -cp $KCORE:$KCLIENT:$SCORE:. Producer
I get a NoClassDefFoundError telling me the following 
The code for the class is
package kafka.examples; import java.util.Properties; import kafka.producer.KeyedMessage; import kafka.producer.ProducerConfig; public class Producer extends Thread { private final kafka.javaapi.producer.Producer<Integer, String> producer; private final String topic; private final Properties props = new Properties(); public Producer(String topic) { props.put("serializer.class", "kafka.serializer.StringEncoder"); props.put("metadata.broker.list", "localhost:9092"); // Use random partitioner. Don't need the key type. Just set it to Integer. // The message is of type String. producer = new kafka.javaapi.producer.Producer<Integer, String>(new ProducerConfig(props)); this.topic = topic; } public void run() { int messageNo = 1; while(true) { String messageStr = new String("Message_" + messageNo); producer.send(new KeyedMessage<Integer, String>(topic, messageStr)); messageNo++; } } } Can anybody point me in the right direction to resolve this error? Do the classes need to go in different directories for some reason?