Hunteerq
Hunteerq

Reputation: 280

Kafka : could not find or load main class installation Windows

I am trying to install Apache Kafka on my computer. I downloaded newest version 2.12-2.0.0. I want to run it on Windows, after typing ".\zookeeper-server-start.bat ../../config/zookeeper.properties" inside \bin\windows directory I am receiving:

Error: Could not find or load main class Files\Java\jdk-10.0.1\lib;C:\Program Caused by: java.lang.ClassNotFoundException: Files\Java\jdk-10/0/1\lib;C:\Program

Java works on my computer properly java -version:

openjdk version "10.0.1" 2018-04-17 OpenJDK Runtime Environment (build 10.0.1+10) OpenJDK 64-Bit Server VM (build 10.0.1+10, mixed mode)

JDK is located inside C:\Program Files\Java\jdk-10.0.1 I have variables:

JAVA_HOME=C:\Program Files\Java\jdk-10.0.1
JDK_HOME=%JAVA_HOME%
JRE_HOME=%JAVA_HOME%\jre
PATH: C:\Program Files\Java\jdk-10.0.1\bin 
CLASSPATH: %JAVA_HOME%\lib;%JAVA_HOME%\jre\

Upvotes: 8

Views: 8052

Answers (5)

Kadyan
Kadyan

Reputation: 43

Just place kafka folder outside the Program Files. Place them in C directory and start again to see the magic. enter image description here

Upvotes: 3

Ashish
Ashish

Reputation: 341

I know, I am late into this query. But 2 cents of mine which I identified.

Please make sure that there should not be any space with your KAFKA_HOME and JAVA_HOME paths. For me, I had the Kafka installation as c:\software\Apache Kafka 3.1\kafka-src

And I thought that it should work as the Kafka installation path (starting from Kafka-src) did not have any space but I was wrong. Please make sure the entire Kafka Installation path (starting from c:) should not have any spaces.

Upvotes: 0

OneCricketeer
OneCricketeer

Reputation: 192013

Your JAVA_HOME (and full Kafka path) cannot contain spaces (i believe there's an open JIRA for fixing this)

Try C:\PROGRA~1\Java\jdk-10.0.1, and if that doesn't work, install Java to somewhere like C:\jdk-X.Y.Z\, as lower versions of Kafka don't support Java 10

In general, though, the recommendation is to use WSL2 (or Docker), not CMD/Powershell

https://www.confluent.io/blog/set-up-and-run-kafka-on-windows-linux-wsl-2/

Upvotes: 9

Toàn Trương
Toàn Trương

Reputation: 1

I got the same issue, and I solved it by renaming the folder in which I store Kafka to new name has no space. But for the case of this post we can not rename folder Program Files then solution is moving Kafka to another folder and make sure the path to this folder does not has space.

Upvotes: 0

Ashwath Iyer
Ashwath Iyer

Reputation: 1

Set the below configurations in your kafka-run-class.bat and try to start the server

SET "JAVA_HOME=C:\Program Files\Java\jdk-10.0.1"

set "CLASSPATH=C:\Program Files\Java\jdk-10.0.1\lib;C:\Program Files\Java\jdk-10.0.1\lib\tools.jar;C:\Program Files\Java\jdk-10.0.1\lib\slf4j-api-1.7.25.jar"

Upvotes: 0

Related Questions