JAVA_HOME is incorrectly set when launching Zookeeper on Windows
Asked Answered
M

8

5

I'm having a "JAVA_HOME is incorrectly set" error when launching Zookeeper on windows with zkServer.cmd while it is correctly set! When I issue %JAVA_HOME% I got C:\Program Files\Java\jdk1.7.0_45 which is the correct directory of the java instalation.

I suspect the problem is due to the space in program files, as when I issue %JAVA_HOME%\bin\java.exe (the command used in zkEnv.cmd) I got:

'C:\Program' is not recognized as an internal or external command, operable program or batch file.

How I can fix this?

Myrnamyrobalan answered 20/8, 2014 at 17:15 Comment(0)
D
7

Quote the path.

"%JAVA_HOME%\bin\java.exe"

Dreamy answered 20/8, 2014 at 17:24 Comment(1)
quote the path of JAVA_HOME as it has space in the path for Program Files.Miseno
C
4

in my environment i setted to:

JAVA_HOME=C:\Progra~1\Java\jdk1.8.0_65


Note for Windows users on 64-bit systems

Progra~1 = 'Program Files'

Progra~2 = 'Program Files(x86)'

Colporteur answered 29/5, 2019 at 12:44 Comment(0)
R
1

I have the same problem. And i fix it.

You can change the content [%JAVA_HOME%\bin\java] to ["%JAVA_HOME%\bin\java"] in zkEnv.cmd. It needs the quota.

then run the zkServer.cmd . it works well.

Ricardoricca answered 16/12, 2015 at 8:43 Comment(0)
H
0

In zkEnv.cmd file, they had changed from JAVA_HOME to JAVA only. I added JAVA in Enviorment Path and it worked, or you can change from JAVA to JAVA_HOME in zkEnv.cmd file and it will work

Harcourt answered 7/9, 2018 at 21:43 Comment(0)
D
0

I had the same problem:

My issue was resolved because Windows editors cannot recognize the space between folders.

Changing from: set JAVA_HOME=C:\Program Files (x86)\Common Files\Oracle\Java\jdk1.8.0_281

to: set JAVA_HOME="C:\Program Files (x86)\Common Files\Oracle\Java\jdk1.8.0_281"

Fixed the Issue for me

Drooff answered 28/3, 2021 at 20:38 Comment(0)
W
0

If JAVA_HOME is not set or you don't have access to set it,

add below to the startup batch files at the top,

set JAVA_HOME=C:"location"\java\jdk1.8.0_192

Waechter answered 26/7, 2021 at 13:27 Comment(0)
R
0

For windows 11, I've added to variables: JAVA_HOME and value C:\Program Files\Java,and then edited variable Path, added %JAVA_HOME%

Regenerate answered 27/12, 2021 at 15:9 Comment(0)
B
0

For windows server 2016 and JDK 11 running via git bash, I kept receiving:

[0.006s][error][logging] Error opening log file '/e/apps/Apache/Kafka/kafka_2.13-3.6.0/bin/../logs/zookeeper-gc.log': No such file or directory

[0.006s][error][logging] Initialization of output 'file=/e/apps/Apache/Kafka/kafka_2.13-3.6.0/bin/../logs/zookeeper-gc.log' using options 'filecount=10,filesize=100M' failed.

Invalid -Xlog option '-Xlog:gc*:file=/e/apps/Apache/Kafka/kafka_2.13-3.6.0/bin/../logs/zookeeper-gc.log:time,tags:filecount=10,filesize=100M', see error log for details.

Error: Could not create the Java Virtual Machine.

Error: A fatal exception has occurred. Program will exit.

I had seen it required a minimum Java version of 8+ and that it was moaning about some logging, I had seen in the kafka-run.sh that it was doing something funky based on the java version with the log files so I set it instead to JDK 8 and everything started properly (zookeeper wise). I then tried to start kafka and it started fine.

Note: my java path and home were messed up/not present so in kafka-run-class.sh I did add at the top:

JAVA_HOME=/C/apps/jdk1.8.0_241

JAVA=/C/apps/jdk1.8.0_241/bin/java

Betrothed answered 16/11, 2023 at 15:21 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.