Iqbal
Iqbal

Reputation: 73

The system cannot find the path specified: Error while starting zookeeper(Apache Kafka)

I am getting the below error while starting Zookeeper server in the command prompt: The system cannot find the path specified. I am using Windows 8 OS, Kafka 2.12 and Java 8 JDK.

I have checked on the below:

  1. Set JAVA_HOME to JDK bin folder.
  2. Set the PATH environment variable correctly using JAVA_HOME as the relevant path.
  3. Set the CLASSPATH environment variable correctly using JAVA_HOME as the relevant path.
  4. Used shortened path in windows to avoid using spaces: Ex: C:\Progra~1 instead of C:\Program Files
  5. Checked on the below commands in the command prompt:

    echo %JAVA_HOME%

    echo %PATH%

    echo %CLASSPATH%

    where java

    java -version

    java -d64 -version

    javac -version

All of them gave me the specified path. However it didn't resolved my issue.

Upvotes: 1

Views: 5869

Answers (4)

Kuldeep Singh
Kuldeep Singh

Reputation: 45

In my case I updated Java version from jdk-11.0.19 to jdk-21.0.5. After this update I started facing the "The system cannot find the path specified:" error from Kafka_2.11-2.3.0. Zookeeper was working fine.

I tried a lot of things as suggested above. Finally I pointed the JAVA variable with the old Java version 11 in the ....\kafka_2.11-2.3.0\bin\windows\kafka-run-class.bat file.

rem Which java to use
rem IF ["%JAVA_HOME%"] EQU [""] (
rem set JAVA=java
rem ) ELSE (
rem set JAVA="%JAVA_HOME%/bin/java"
rem )

set JAVA="C:/Program Files/Eclipse Adoptium/jdk-11.0.19.7-hotspot/bin/java"

It started working.

Note: Kafka_2.11-2.3.0 is not supporting Java 21

Upvotes: 0

sumit singh
sumit singh

Reputation: 57

I was also facing the same issue: My java home set was

    C:\Program Files\Java\jdk1.8.0_144\bin

Then i did the following change:

1)changed the jdk location to C:\Java\jdk1.8.0_144\bin as earlier location was containing spaces between Program and Files.

2)Also i need to change the kafka-run-class.bat file from

   IF ["%JAVA_HOME%"] EQU [""] (
set JAVA=java
    ) ELSE (
set JAVA="%JAVA_HOME%/bin/java"

) to

    IF ["%JAVA_HOME%"] EQU [""] (
set JAVA=java
    ) ELSE (
set JAVA="%JAVA_HOME%/java"

) . As my java home already contains /bin suffix.So either remove the bin suffix from your java home or modify the kafka-run-class.

But still i was getting same error when running from the command prompt.Then i closed the cmd and again opened the new command prompt and run the following command and it run successfully.

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

Note:If you modify the system variable then you need to restart the system.

Upvotes: 2

Iqbal
Iqbal

Reputation: 73

There is this file kafka-run-class.bat which gets referenced in most of the kafka scripts. It sets the JAVA parameter depending on the JAVA_HOME variable mentioned below: set JAVA="%JAVA_HOME%/bin/java"

We need to modify this since JAVA_HOME already contains path until 'bin'. So now Kafka tries to append an extra bin directory to the path. We need to alter this as mentioned below: set JAVA="%JAVA_HOME%/java"

Now on starting the zookeeper again in a fresh command prompt the error is gone and the zookeeper starts fine.

Upvotes: 1

vivekdubey
vivekdubey

Reputation: 510

I think JAVA_HOME should keep till JDK path not JDK\bin.

Upvotes: 4

Related Questions