简体   繁体   中英

JAVA_HOME is incorrectly set when launching Zookeeper on Windows

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?

Quote the path.

"%JAVA_HOME%\\bin\\java.exe"

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)'

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.

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

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

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

对于 Windows 11,我添加到变量: JAVA_HOME和值C:\\Program Files\\Java ,然后编辑变量Path ,添加%JAVA_HOME%

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM