Boris K
Boris K

Reputation: 3580

Running Kafka on Windows 10 fails: The system cannot find the path specified

I'm trying to run Kafka locally. I've got Zookeeper installed and running. I've downloaded the binaries for Kafka 2.11-1.1.0. I've adjusted the location of the logs in server.config, to a valid path. When I run .\bin\windows\kafka-server-start.bat .\config\server.properties, I get an error that says

The system cannot find the path specified.

I can see that both those files exist on my computer in the proper locations-what should I be troubleshooting? kafka-server-start: check server.config: check

Upvotes: 16

Views: 37758

Answers (16)

Balaji
Balaji

Reputation: 31

Path not found when trying to run Kafka in the local server, is basically due to by default the zookeeper.properties file present in kafka/config folder having dataDir=tmp/zookeeper_data which would not point to any location in the system.

  1. So you have to change dataDir in zookeeper.properties to:

    dataDir=C:/Users/hp/Documents/kafka/zookeeper_data (like this) dataDir=your_kafka_folder_path + /zookeeper_data

Also, consider that you have to use Java version > 8 and ensure you added its path to environment variables.

Ensure this by checking:

java -version

In your cmd.

  1. Also change the log.dir in server.properties

This will also follow the default fashion of tmp/kafka_logs, which would point to an unexisting path in your system.

So, change the log.dir to log.dirs=C:/Users/hp/Documents/kafka/kafka-logs

Where log.dirs=your_kafka_folder_path + /kafka-logs

Upvotes: 0

Manash Ranjan Dakua
Manash Ranjan Dakua

Reputation: 311

I relocate it into the new path and I provide this zookeeper bin path properly into environment variable setup and it work for me fine.

Upvotes: 0

Kiran Garag
Kiran Garag

Reputation: 1

Make sure your java_home path is correct with respect to the directory. This issue happens when the java_home path is wrong.

Upvotes: 0

sina zarei
sina zarei

Reputation: 117

In the case of main, in Environment variables set JAVA_HOME in Both part User variables & system variables And the problem resolved!

Upvotes: 0

user448477
user448477

Reputation: 85

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

Upvotes: 2

Aliaksei Halkin
Aliaksei Halkin

Reputation: 11

I tried all the solutions, I changed JAVA_HOME different methods and it didn't work. Solution: launch cmd.exe as administrator and execute the command: set JAVA_HOME=%ProgramFiles%\Java\jdk-17.0.1 (only will choice your jdk version)

Upvotes: 1

Shubham Poddar
Shubham Poddar

Reputation: 1

I had been stuck with this for quite some time. Following are the steps I followed to resolve the issue:

  • In enviroment variables set JAVA_HOME to C:\Program Files\Common Files\Oracle\Java\javapath
  • If the above doesn't resolve the issue, check if in kafka/bin/kafka-run-class.sh JAVA=$JAVA_HOME/bin/java is used. In this case you might need to simply create a folder bin under javapath and copy the java.exe to it. This should fix the isssue.

Upvotes: 0

Virendra Prajapati
Virendra Prajapati

Reputation: 11

I facing same issue and fixed with below steps as following:

  • Make sure your environment variable as:

    JAVA_HOME=C:\Program Files\Java\jdk1.8.0_261

    ZOOKEEPER_HOME=C:\apache-zookeeper-3.6.2

    KAFKA_HOME=C:\kafka_2.13-2.7.0

  • Edit the 'Path' in system variable and type:
    %JAVA_HOME% / bin, %ZOOPKEEPER_HOME / bin and %KAFKA_HOME% / bin

  • Now, open the terminal, Run zoopkeeper and kafka

    For Zoopkeeper: zkserver

    For Kafka: bin\windows\kafka-server-start.bat .\config\server.properties

It runs without an any issues and errors.

Upvotes: 1

Raj
Raj

Reputation: 125

A simple solution that worked for me - Open kafka-run-class.sh file, goto line num 306, enclose $JAVA within "".

exec "$JAVA" $KAFKA_HEAP_OPTS $KAFKA_JVM_PERFORMANCE_OPTS $KAFKA_GC_LOG_OPTS $KAFKA_JMX_OPTS $KAFKA_LOG4J_OPTS -cp $CLASSPATH $KAFKA_OPTS "$@"

This problem appears if there a space in your Java path. Either remove the space from your Java installation path or enclose the path within double-quotes.

Upvotes: -1

P Moran
P Moran

Reputation: 1842

I had this problem as well. In my case I have java installed in C:\Java\bin and JAVA_HOME defined as

JAVA_HOME=c:\Java\bin

I needed to change

c:\Tools\kafka_2.12-2.2.0\bin\kafka-run-class.sh

lines 224 to 229 from this

# Which java to use
if [ -z "$JAVA_HOME" ]; then
  JAVA="java"
else
  JAVA="$JAVA_HOME/bin/java"
fi

to this:

# Which java to use
if [ -z "$JAVA_HOME" ]; then
  JAVA="java"
else
  JAVA="$JAVA_HOME/java"
fi

because it was assigning java to C:\Java\bin/bin/java which was then failing on 306 of the same file.

BTW: I'm using a git bash shell in windows. This allows me to run the bin/*.sh scripts instead of the bin/windows/*.bat scripts

Also I changes the value of the dataDir in

C:\Tools\kafka_2.12-2.2.0\config\zookeeper.properties

to

dataDir=C:\\Tools\\kafka_2.12-2.2.0\\zookeeper-data

Upvotes: 11

Gonen I
Gonen I

Reputation: 6127

As many have mentioned, this can happen if any of the kafka *.bat scripts that you run ( including zookeeper) refer to a bad JAVA_HOME system variable, or one containing a space.

You can solve this by changing JAVA_HOME to the shortened path name. For example

set JAVA_HOME=C:\Progra~1\Java\jdk-11.0.1

P.S.

For convenience, I created a CMD desktop shortcut that sets the JAVA_HOME to be right for Kafka, and CDs to my kafka installation. My Desktop shortcut is as follows:

%windir%\System32\cmd.exe /k set JAVA_HOME=C:\Progra~1\Java\jdk-11.0.1&  f: & cd f:\kafka\kafka_2.12-2.2.0

Upvotes: 6

STaefi
STaefi

Reputation: 4377

I had the same problem, but it wasn't because of the malformed path of JAVA_HOME environment variable.

It was because I had extracted my kafka bineries in a path which contains spaces!

First it was here:

E:\Apache Kafka\kafka_2.11-2.1.0

Then I relocate it in this new path (which doesn't have any spaces!):

E:\ApacheKafka\kafka_2.11-2.1.0

And the problem resolved!

Hope this helps.

Upvotes: 5

daveD
daveD

Reputation: 976

Late reply, but I hope it helps someone. I had the same issue, and found someone had updated JAVA to a newer version, i.e. my JAVA_HOME system variable was pointing to a folder that didnt exist. Strange as I hadnt done it, but the answers above inspired me to check it.

Upvotes: 1

Joyson
Joyson

Reputation: 3040

I faced this issue while running the kafka-server-start.bat command. I double checked to ensure that there was no spaces in the kafka binaries path as well as correct syntax in JAVA_HOME.

Finally realized that the issue was due to a space in the JAVA_HOME path.

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

There is a space between Program and Files. I changed the directory of Java and updated the JAVA_HOME variable to

C:\Java\jdk1.7.0_51

This change solved my issue. I used the setx command to change the value in JAVA_HOME.

setx -m JAVA_HOME "C:\Java\jdk1.7.0_51"

Upvotes: 27

OneCricketeer
OneCricketeer

Reputation: 191963

To add to the existing answer, you can also get the error when running the Kafka provided zookeeper-server-start command (and almost all other scripts in the bin/windows folder) because it also utilizes kafka-run-class, and therefore relies on a valid JAVA_HOME environment variable path.

cd D:\Downloads\kafka
.\bin\windows\zookeeper-server-start.bat .\config\zookeeper.properties

Upvotes: 2

Boris K
Boris K

Reputation: 3580

Turns out that this error is being thrown by kafka-run-class.bat because the path to JAVA_HOME in system variables is malformed (in my case, I had added /bin to it.) Removing /bin from the path, and having it be an existing Java installation folder, makes everything run fine.

Upvotes: 5

Related Questions