I'm trying to run Kafka message queue on Windows.
I'm usin this tutorial - https://dzone.com/articles/running-apache-kafka-on-windows-os
When i try to run it with comand - .\bin\windows\kafka-server-start.bat .\config\server.properties
and i get an error: The input line is too long. The syntax of the command is incorrect.
kafka location - C:\kafka_2.11-1.0.0
This is because of the long length of the path because of the folder name 'kafka_2.11-1.0.0'. Just rename the folder to something small, like just 'kafka'.
The Problem
The kafka-run-class.bat
file performs a bunch of CLASSPATH :concat calls that make the CLASSPATH very long.
Depending on your environment, too long: Windows cmd.exe environment has a limit of 8191 characters.
Solutions
Edit kafka-run-class.bat
so that ...
libs/*
)Example
Here is an example of an edit to kafka-run-class.bat
(source) that uses the 2nd approach:
replace ...
rem Classpath addition for release
for %%i in ("%BASE_DIR%\libs\*") do (
call :concat "%%i"
)
... by this ...
rem Classpath addition for release
call :concat "%BASE_DIR%\libs\*;"
Just moving the Kafka path to a much smaller root path solved the issue. For e.g. "C:\Kafka"
Above both options didn't work for me.
I have just moved an unzipped directory to C:/ drive and started power shell in Administrator mode and tried the desired commands, the zookeeper and broker started smoothly.
Place kafka close to the root of your drive so that the path to it is very short.
When you run those Kafka batch files included in the windows directory, they muck with your environment variables (the classpath one) and can create a very long input line to actually run the command/jar.
Also as some others pointed out, ensure you downloaded the binary (yes even though on the Kafka site it is called the Scala binary and there's no mention of Windows anywhere, which can confuse people), not the source code. Also confusing to the lay-user, the source distribution looks similar to the binary distribution when uncompressed, it has all the batch files for example but they won't run.
Windows command-line has issues with long command execution. Use Powershell instead.
put all the files in other drive like D: or E: and run the command
I have copied everything to C:/tools/kafka and it works fine. The problem was indeed the too long path to kafka.
For me, it worked only after keeping the Kafka folder right under C directory, so the path looked like C:\Kafka. I am sure this will work.
I tried below command but gives me same error
C:\kafka>.\bin\windows\zookeeper-server-start.bat .\config\zookeeper.properties
This happens because path gets append in classpath when we are continuously executing same command on same cmd.
Close your command prompt and open once again and then start zookeeper server.
For Windows just keep Kafka Folder path short For eg - D/dev/kafka/bin/windows
Kafka folder/directory path length needs to be decreased. Use short folder/directory path then it should start working.
Closing Zookeeper and Kafka cmd window and reopening it again worked for me. I tried all options above except powershell.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With