简体   繁体   中英

How does %JAVA_HOME% work in Windows PATH?

I am using Puppet to automate the installation of java. When doing this we first set the JAVA_HOME environment to whatever version of Java we are installing. Then we have it prepend %JAVA_HOME% to Windows PATH . That way if any other version of java is being used it will not use it and instead use whatever is in JAVA_HOME . The issue I am running in to is when I run dir %JAVA_HOME% I get back

"The system cannot find the path specified"

Yet when I echo %JAVA_HOME% it gives me the correct path to the JDK.

Should I expect dir %JAVA_HOME% to show me the directory contents? If not, why? We have another program that works with the exact same Puppet method and when doing dir M2_HOME (maven) it will correctly print out the directory contents.

Java -version still works

您需要从Java home删除bin并添加%java_home%/ bin

Strange resolution. The original way we were doing it does work. However JAVA_HOME can not be C:\\Program Files\\xxxxxxx it needs to be C:\\PROGRA~1\\xxxxxx for it to list directory contents.

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