Getting Error as Exception in thread "main" java.lang.NoClassDefFoundError

Dear Members,

Am trying to execute the custom producer written in JAVA as Maven project and using STS to develop the code. while I complied and trying to execute as Jar file in it versity lab, Hortonworkssandbox both am getting an error below pasted.
Help me to solve the issue.

Java Code

package producer;

import org.apache.kafka.clients.producer.KafkaProducer;
import org.apache.kafka.clients.producer.ProducerRecord;
import org.apache.kafka.clients.consumer.;
import java.util.

public class BasicProducer {

public static void main(String[] args) {
	if (args.length != 1) {
		System.out.println("Kindly provide the arguments");

	Long events = Long.parseLong(args[0]);

	Properties props = new Properties();
	props.put("broker.list", ",");
	props.put("acks", "all");
	props.put("retries", 0);
	props.put("key.serializer", "org.apache.kafka.common.serialization.IntegerSerializer");
	props.put("value.serializer", "org.apache.kafka.common.serialization.StringSerializer");

	String topic = "BasicProducer";

	KafkaProducer<Integer, String> producer = new KafkaProducer<Integer, String>(props);
	ProducerRecord<Integer, String> producerRecord = null;
	for (int cEvent = 0; cEvent < events; cEvent++) {
		producerRecord = new ProducerRecord<Integer, String>(topic, new Integer(cEvent),
				"This is message no" + cEvent);
		System.out.println("Record ");






java -cp /home/anuvenkatesheee/kafkajars/kafkaDemo-0.0.1-SNAPSHOT.jar producer.BasicProducer 5


Exception in thread “main” java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
at org.apache.kafka.clients.producer.KafkaProducer.(
at producer.BasicProducer.main(
Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
at java.lang.ClassLoader.loadClass(
at sun.misc.Launcher$AppClassLoader.loadClass(
at java.lang.ClassLoader.loadClass(