[英]How does %JAVA_HOME% work in Windows PATH?
I am using Puppet to automate the installation of java. 我正在使用Puppet自动执行Java安装。 When doing this we first set the
JAVA_HOME environment
to whatever version of Java we are installing. 在执行此操作时,我们首先将
JAVA_HOME environment
设置为要安装的Java版本。 Then we have it prepend %JAVA_HOME%
to Windows PATH
. 然后,我们将
%JAVA_HOME%
附加到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
. 这样,如果使用任何其他版本的java,它将不使用它,而是使用
JAVA_HOME
任何内容。 The issue I am running in to is when I run dir %JAVA_HOME%
I get back 我正在运行的问题是当我运行
dir %JAVA_HOME%
我回来了
"The system cannot find the path specified"
“该系统找不到指定的路径”
Yet when I echo %JAVA_HOME%
it gives me the correct path to the JDK. 但是,当我
echo %JAVA_HOME%
它为我提供了通往JDK的正确路径。
Should I expect dir %JAVA_HOME%
to show me the directory contents? 我是否应该希望
dir %JAVA_HOME%
向我显示目录内容? 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. 我们还有另一个程序可以使用完全相同的Puppet方法,并且在执行
dir M2_HOME
(maven)时,它将正确打印出目录内容。
Java -version
still works Java -version
仍然有效
您需要从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. 但是,
JAVA_HOME
不能为C:\\Program Files\\xxxxxxx
它必须为C:\\PROGRA~1\\xxxxxx
才能列出目录内容。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.