蚂蚁+ Vista 64:“无法找到tools.jar” (jre/jdk冲突?)
我正在尝试在 vista 64 环境中使用 ant 来构建一些 docbook/xml 文件。
但是,我无法解决此错误消息。有人有建议吗?
C:\Users\Robert Admin>ant 无法找到tools.jar。预计在 C:\Program Files\Java\jre6\li 中找到它 b\工具.jar 构建文件:build.xml 不存在! 构建失败
谷歌搜索,我看到这个tools.jar消息是ant无法找到jdk的结果。事实上,C:\Program Files\Java\jre6\li b\tools.jar 是与另一个程序一起安装的 JRE(我猜)。 Tools.jar 位于这里:C:\Program Files\Java\jdk1.6.0_22\lib
我似乎无法告诉 Ant 查看 JDK 路径,只能查看已经存在的 JRE 路径那里。 (从Ant文档来看,看来JRE是不够的)。
C:\Users\Robert Admin>echo %JAVA_HOME%
C:\Program Files\Java\jdk1.6.0_22\bin
C:\Users\Robert Admin>ant
Unable to locate tools.jar. Expected to find it in C:\Program Files\Java\jre6\li
b\tools.jar
Buildfile: build.xml does not exist!
Build failed
C:\Users\Robert Admin>echo %ANT_HOME%
I:\My Documents\1latest\ant
C:\Users\Robert Admin>where java
C:\Windows\System32\java.exe
C:\Program Files (x86)\Java\jre6\bin\java.exe
C:\Program Files\Java\jdk1.6.0_22\bin\java.exe
C:\Users\Robert Admin>java -version
java version "1.6.0_22"
Java(TM) SE Runtime Environment (build 1.6.0_22-b04)
Java HotSpot(TM) 64-Bit Server VM (build 17.1-b03, mixed mode)
更新#1。我尝试卸载64位jdk并安装32位jdk。结果:
C:\Users\Robert Admin>java -version
java version "1.6.0_22"
Java(TM) SE Runtime Environment (build 1.6.0_22-b04)
Java HotSpot(TM) 64-Bit Server VM (build 17.1-b03, mixed mode)
C:\Users\Robert Admin>ant
Unable to locate tools.jar. Expected to find it in C:\Program Files\Java\jre6\li
b\tools.jar
Buildfile: build.xml does not exist!
Build failed
C:\Users\Robert Admin>echo %JAVA_HOME%
C:\Program Files (x86)\Java\jdk1.6.0_22\bin
I'm trying to use ant in a vista 64 environment to build some docbook/xml files.
However, I can't resolve this error message. Anybody have suggestions?
C:\Users\Robert Admin>ant
Unable to locate tools.jar. Expected to find it in C:\Program Files\Java\jre6\li
b\tools.jar
Buildfile: build.xml does not exist!
Build failed
Googling around, I see that this tools.jar message is the result of ant not being able to find the jdk. In fact, C:\Program Files\Java\jre6\li
b\tools.jar is a JRE installed with another program (I'm guessing). Tools.jar is located here: C:\Program Files\Java\jdk1.6.0_22\lib
I can't seem to tell Ant to look in the JDK path, only the JRE path which was already there. (Judging from the Ant documentation, it seems that JRE is insufficient).
C:\Users\Robert Admin>echo %JAVA_HOME%
C:\Program Files\Java\jdk1.6.0_22\bin
C:\Users\Robert Admin>ant
Unable to locate tools.jar. Expected to find it in C:\Program Files\Java\jre6\li
b\tools.jar
Buildfile: build.xml does not exist!
Build failed
C:\Users\Robert Admin>echo %ANT_HOME%
I:\My Documents\1latest\ant
C:\Users\Robert Admin>where java
C:\Windows\System32\java.exe
C:\Program Files (x86)\Java\jre6\bin\java.exe
C:\Program Files\Java\jdk1.6.0_22\bin\java.exe
C:\Users\Robert Admin>java -version
java version "1.6.0_22"
Java(TM) SE Runtime Environment (build 1.6.0_22-b04)
Java HotSpot(TM) 64-Bit Server VM (build 17.1-b03, mixed mode)
Update #1. I tried uninstalling the 64 bit jdk and installing the 32 bit jdk. Result:
C:\Users\Robert Admin>java -version
java version "1.6.0_22"
Java(TM) SE Runtime Environment (build 1.6.0_22-b04)
Java HotSpot(TM) 64-Bit Server VM (build 17.1-b03, mixed mode)
C:\Users\Robert Admin>ant
Unable to locate tools.jar. Expected to find it in C:\Program Files\Java\jre6\li
b\tools.jar
Buildfile: build.xml does not exist!
Build failed
C:\Users\Robert Admin>echo %JAVA_HOME%
C:\Program Files (x86)\Java\jdk1.6.0_22\bin
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(14)
我遇到了同样的问题,因为我的 JAVA_HOME 路径设置不正确(就像OP一样)。被设置到了jdk的bin下。
所以就设置为:
C:\Program Files (x86)\Java\jdk1.6.0_25\bin
当它应该设置为:
C:\Program Files (x86)\Java\jdk1.6.0_25
更新此环境变量为我修复了它。
I had the same problem because my JAVA_HOME path was set incorrectly (just like the OP's). It was set to the bin of the jdk.
So it was set to:
C:\Program Files (x86)\Java\jdk1.6.0_25\bin
When it should have been set to:
C:\Program Files (x86)\Java\jdk1.6.0_25
Updating this environmental variable fixed it for me.
我在 64 位 Windows 7 机器和 Ant 1.8.2 上遇到了这个问题。解决方案是使用 #bigfix 提到的管理工具来设置环境变量。请按照 Windows 的 Ant 安装说明进行操作。但不要将路径设置为%ANT_HOME%\bin。相反,请使用显式路径,例如 C:\jdk-1.5.0.05\bin。
我的第一次测试失败了,因为我的命令窗口已经打开并使用旧的环境变量。关闭它并打开一个新的。然后尝试测试一下。这对我有用。
I had this problem on a 64-bit Windows 7 machine and Ant 1.8.2. The solution was to use the admin tools mentioned by #bigfix to set the environment variables. Follow the Ant installation instructions for Windows. But do not set the path as %ANT_HOME%\bin. Instead, use an explicit path such as C:\jdk-1.5.0.05\bin.
My first test failed because my command window was already open and using the old env vars. Close it and open a new one. Then try the test. It worked for me.
我通过在计算机中创建 JAVA_HOME 解决了这个问题 - >属性->环境变量
在命令行中手动设置不起作用
-b
I fixed this by creating JAVA_HOME in computer-> properties-> env variables
Manual setup in command line did not work
-b
我通过将系统变量 JAVA_HOME 创建到 C:\Program Files\Java\jdk1.6.0_25 解决了该问题。不要在其后面添加分号。首先我加了分号,结果出现错误。我删除了分号并且它起作用了。
I solved the problem by creating system variable JAVA_HOME to C:\Program Files\Java\jdk1.6.0_25. Don't put the semi colon after it. First of all I put the semi colon and there was an error. I removed the semi colon and it worked.
您所需要做的就是在您的环境中设置 JAVA_HOME 路径。在 Windows 7 中,转到“系统属性 -> 高级 -> 环境变量”并添加 JAVA_HOME。我的例子的价值是:
这为我解决了这个问题。该变量将 Ant 指向正确的 Java 位置。
All you need is to set JAVA_HOME path in your environment. In Windows 7 go to "System Properties -> Advanced -> Environment Variables" and add JAVA_HOME. The value in my case was:
This resolved the issue for me. This variable points Ant to the correct Java location.
我知道这个线程有些旧了..但我现在也遇到了..我所做的是将tools.jar复制到jre/lib文件夹中并且工作正常。
我在 Windows 7 、 JDK 1.7 环境中并尝试安装 ant 1.8.2
谢谢
I know this thread is some what old..but i faced it just now too..what i did was copy that tools.jar into jre/lib folder and worked fine.
I'm in Windows 7 , JDK 1.7 environment and trying to install ant 1.8.2
Thanks
您可能使用的是 C:\Windows\system32 目录中的 java,而不是已安装的 JDK。我设置了一个 JAVA_HOME 环境变量,并将 %JAVA_HOME%\bin 放在路径的开头,以及离开时出现的问题。
you may be using the java in the C:\Windows\system32 directory rather then the installed JDK. I set a JAVA_HOME environmental variable and put %JAVA_HOME%\bin at the start of my path and the problems when away.
你为什么不试试 32 位版本呢?您安装的 32 和 64 两个版本之间可能存在问题。尝试 32 位版本,这样您就不会看到任何 64 位版本。
它应该可以解决你的问题。
why don't you try the 32 bit version. there could be a problem between the two versions you have installed being 32 and 64. try the 32 bit version so ur not seeing any 64 bit versions.
it should fix ur problem.
我的环境有这个问题:
我收到 ant 构建消息为“
无法找到 tools.jar。预计在 E:\Java 中找到它” \jre6\lib\tools.jar
”,我的 JDK 安装在E:\Java\jdk1.6.0_33\
,JRE 安装在E:\Java\jre6\原因
:
我的问题是我在两个不同位置的 PATH 系统环境变量中设置了两次 ANT_HOME(意味着中间的一些其他变量)。
解决方案:
我删除了指向错误位置的
ANT_HOME
变量,一切正常。I had this issue with Environment as :
I Was getting ant build message as "
Unable to locate tools.jar. Expected to find it in E:\Java\jre6\lib\tools.jar
", where my JDK was installed atE:\Java\jdk1.6.0_33\
and JRE atE:\Java\jre6\
Cause:
My issue was that I have
ANT_HOME
was set twice in the PATH system Environment variable at two different places (means some other variables in between).Solution:
I removed the
ANT_HOME
variable that pointed to the wrong location and everything worked fine with me.我曾经遇到过同样的
ant setup
问题。提升和我删除
%PATH%
环境中所有jre路径并添加jdk bin路径是一样的。最后,我输入%ANT_PATH%/bin
而不是%ANT_PATH%\bin
。有用。可能有帮助。
I once faced the same problem of
ant setup
. The promotion is just the same asI deleted all jre path in
%PATH%
environment and add jdk bin path. Finally I type%ANT_PATH%/bin
instead of%ANT_PATH%\bin
. It works.May help.
我遇到了同样的问题。
成功解决。
因此,如果您没有看到此变量,则意味着您的变量没有为运行 jenkins 的用户设置。您需要将“JAVA_HOME”放入环境变量的“系统变量”部分,而不是“用户变量”。
在此之后重新启动詹金斯,您的问题必须得到解决。
I got the same issue.
Successfully resolved.
So if you do not see this variable it means that your variable was not set for the user that jenkins run under. You need to put "JAVA_HOME" in to the "system variables" section of environment variables, not "user variables".
restart jenkins after this and your problem must be fixed.
当运行 %ANT_HOME%\bin\ant.bat 时,我收到“C:\Program”未被识别为内部或外部命令、可操作程序或批处理文件错误,
我发现我需要将命令包装在双引号中引号以便在路径字符串上进行正确的转义。
使固定:
“%ANT_HOME%\bin\ant.bat” --NOT-- %ANT_HOME%\bin\ant.bat
希望有帮助!
I was getting a "C:\Program" is not recognized as an internal or external command, operable program or batch file error, when running %ANT_HOME%\bin\ant.bat
I found that I needed to wrap the command in double-quotes in order to get the proper escaping to happen on the path string.
FIX:
"%ANT_HOME%\bin\ant.bat" --NOT-- %ANT_HOME%\bin\ant.bat
Hope that helps!
谢谢,这也适用于使用 Java x64 的 Windows 8 x64。
我不想将所有这些垃圾添加到我的系统设置中,因此我创建了一个批处理文件,在我想要使用 Android SDK 之前运行该文件。这里是
Thanks, this also works on Windows 8, x64, using Java x64.
I didn't want to add all that junk to my system settings so I created a batch file that I'd run just before I wanted to use the Android SDK. Here it is
我将添加我遇到的另一个问题。
顺便说一句,这里的答案也对我有用。我必须将我的 java 目录指向特定的 SDK 版本。非常感谢。
但我要补充一点,我必须以管理员身份安装 SDK,否则它不会提取 tools.jar。我在其他地方找到了这个答案,我希望它可以帮助有人在这里重复它。
I am going to add one other issue that I had with this.
BTW, the answer here worked for me too. I had to point my java directory to the specific SDK version. Thank you very much.
But I'm going to add that I had to install the SDK as an administrator, or it didn't extract tools.jar. I found this answer elsewhere, and I hope it helps someone to repeat it here.