Kafka : could not find or load main class installation Windows
Asked Answered
I

5

7

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\
Intelligencer answered 31/8, 2018 at 13:45 Comment(1)
I had similar issues under windows and solved by using git bash and the .sh version of the executables of kafka and zookeeperRuction
G
8

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/

Glyconeogenesis answered 31/8, 2018 at 23:53 Comment(2)
I was using the 2.6.0 version and had the JAVA_HOME containing spaces as well, but what solved the issue for me was not JAVA_HOME but rather moving apache kafka binaries so the path doesn't contain spaces.Schiffman
yeap, my folder have some space on. then I put underline on the name instead of space. thanksClubby
S
2

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

Sensuality answered 6/12, 2023 at 13:33 Comment(2)
You will need to edit your answer and add the code that you have written or used. Screenshots or text are less helpful than pasted text.Aero
works for me! thanks!Familiarize
G
0

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"

Goober answered 4/3, 2019 at 4:13 Comment(1)
kafka-run-class needs kafka libraries on the classpath as wellGlyconeogenesis
S
0

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.

Sling answered 7/9, 2021 at 17:10 Comment(1)
As answered in my post, Using PROGRA~1 is how to "fix" the program files path having spacesGlyconeogenesis
P
0

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.

Providence answered 10/8, 2022 at 9:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.