classpath is empty. please build the project first

If anyone else is facing this issue:

  • Note: Do not download a source files from appache kafka, download a binary file
  • Download Kafka from here: Link
  • Also follow this link for any additional information
  • Also this group has some additional information

I had the exact same problem and I finally solved it. the problem is that you have space character in your path (inside folder names) which causes "dirname" command to receive more than one argument.

Therefore, in order to solve, you only need to remove space from folder names within your Kafka folder path.


Follow below steps for windows & kafka 0.9.0.0 (same steps will go with lower versions of kafka) First download binary from: https://www.apache.org/dyn/closer.cgi?path=/kafka/0.9.0.0/kafka_2.11-0.9.0.0.tgz

extract to your particular folder and then

Step 1: create new directories in your kafka directory

 - kafka-logs
 - zookeeper

your directory after step 1 will be :

 - bin 
 - config
 - kafka-logs
 - libs
 - site-docs
 - zookeeper

Step 2: Open config/server.properties and change below property

 - log.dirs={fullpath}/kafka-logs

Step 3: Open config/zookeeper.properties and change belwo property

 - dataDir={fullpath}/zookeeper

Step 4: create a run.bat file under bin/windows folder with following script:

start zookeeper-server-start.bat ..\..\config\zookeeper.properties

TIMEOUT 10

start kafka-server-start.bat ..\..\config\server.properties

exit

You can change timeout for your convenience.


Here i think you downloaded kafka source. you need to download binary

https://www.apache.org/dyn/closer.cgi?path=/kafka/0.9.0.0/kafka_2.11-0.9.0.0.tgz


Follow below steps to resolve this error.

step1: Get inside kafka downloaded folder

cd kafka-2.5.0-src

step2: Run gradle

./gradlew jar 

step3: Once build is successful, start the kafka server

bin/zookeeper-server-start.sh config/zookeeper.properties
bin/kafka-server-start.sh config/server.properties

Now Kafka will be starts on localhost:9092