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 (same steps will go with lower versions of kafka) First download binary from:

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/ and change below property

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

Step 3: Open config/ 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\


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


You can change timeout for your convenience.

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

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/ config/
bin/ config/

Now Kafka will be starts on localhost:9092