java 为什么 ant 在错误的目录中寻找 tools.jar?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13964785/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Why is ant looking for tools.jar in the wrong dir?
提问by DiverseAndRemote.com
I am trying to execute `ant -version' and I get
我正在尝试执行 `ant -version' 并且我得到
C:\Users\owner>ant -version
Unable to locate tools.jar. Expected to find it in C:\Program Files\Java\jre7\lib\tools.jar
Apache Ant(TM) version 1.8.4 compiled on May 22 2012
I checked all of my environment variables and I cant find a reference to C:\Program Files\Java\jre7
我检查了所有环境变量,但找不到对 C:\Program Files\Java\jre7
I have the JDK and JRE installed at C:\Program Files (x86)\Java\jre7
and C:\Program Files (x86)\Java\jdk1.7.0_10
我有JDK和JRE安装在C:\Program Files (x86)\Java\jre7
与C:\Program Files (x86)\Java\jdk1.7.0_10
I also have stuff in C:\Program Files\Java\jre7
and C:\Program Files\Java\jdk1.7.0_10
我也有东西在C:\Program Files\Java\jre7
和C:\Program Files\Java\jdk1.7.0_10
Can anyone tell me why ant is looking in the wrong directory?
谁能告诉我为什么 ant 在错误的目录中查找?
I have seen a bunch of other questions on stackoverflow but none of them solve my issue.
我在 stackoverflow 上看到了很多其他问题,但没有一个能解决我的问题。
output of %path% is
%path% 的输出是
C:\Users\owner>echo %path%
%CommonProgramFiles%\Microsoft Shared\Windows Live;C:\Windows\system32;C:\Window
s;C:\Windows\System32\Wbem;C:\Program Files (x86)\CyberLink\Power2Go;C:\Program
Files (x86)\ATI Technologies\ATI.ACE\Core-Static;c:\Program Files (x86)\Microsof
t SQL Server\Tools\binn\;C:\Program Files (x86)\QuickTime\QTSystem\;C:\Window
s\System32\WindowsPowerShell\v1.0\;C:\Program Files\Java\jdk1.6.0_24\bin;C:\Prog
ram Files\TortoiseSVN\bin;C:\Program Files (x86)\Java\jdk1.7.0_10;C:\Program Fil
es (x86)\Android\android-sdk\tools\apache-ant-1.8.4\bin;C:\Program Files (x86)\A
ndroid\android-sdk\platform-tools\;C:\Program Files (x86)\Android\android-sdk\to
ols\;C:\Program Files\Common Files\Microsoft Shared\Windows Live
C:\Users\owner>echo %JAVA_HOME%
%ProgramFiles(x86)%\Java\jdk1.7.0_10
采纳答案by DiverseAndRemote.com
I just figured out what it was
我才知道那是什么
changing %JAVA_HOME% from %ProgramFiles(x86)%\Java\jdk1.7.0_10
to C:\Program Files (x86)\Java\jdk1.7.0_10
fixed it.
将 %JAVA_HOME% 从更改%ProgramFiles(x86)%\Java\jdk1.7.0_10
为C:\Program Files (x86)\Java\jdk1.7.0_10
修复它。
回答by Perception
Ant does (unfortunately) rely on the JAVA_HOME
system property. You will want to make sure that this property points to a valid JDK installation (and not a JRE).
Ant 确实(不幸的是)依赖于JAVA_HOME
系统属性。您需要确保此属性指向有效的 JDK 安装(而不是 JRE)。