“无法找到tools.jar"跑蚂蚁的时候 [英] "Unable to locate tools.jar" when running ant

查看:31
本文介绍了“无法找到tools.jar"跑蚂蚁的时候的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

运行 ant 时,我收到以下消息:

When running ant, I get the following message:

无法找到 tools.jar.预计在 C:\Program Files\Java\jre6\lib\tools.jar

我将 JAVA_HOME 设置为 C:\Program Files\Java\jdk1.7.0_02,PATH 包括 C:\Program Files (x86)\Java\jdk1.7.0_02\bin,CLASSPATH包括C:\Program Files (x86)\Java\jdk1.7.0_02,ANT_HOME设置为C:\ant.

I have JAVA_HOME set to C:\Program Files\Java\jdk1.7.0_02, PATH includes C:\Program Files (x86)\Java\jdk1.7.0_02\bin, CLASSPATH includes C:\Program Files (x86)\Java\jdk1.7.0_02, and ANT_HOME is set to C:\ant.

似乎 ant 忽略了所有这些设置并在其他地方寻找 tools.jar.没有指向 jre6 路径的环境变量.任何想法为什么?

It seems that ant is ignoring all of these settings and looking for the tools.jar somewhere else. There are no environment variables which point to the jre6 path. Any ideas why?

推荐答案

有两个看起来像 JDK 的目录.

There are two directories that looks like JDK.

  C:\Program Files\Java\jdk1.7.0_02
  C:\Program Files (x86)\Java\jdk1.7.0_02\

这可能是因为同时安装了 64 位和 32 位 JDK?无论如何,ant.bat 看到的 java.exe 应该来自 JDK.如果 JRE 的 java.exe 在路径中排在最前面,则将用于猜测 JDK 位置.

This may be due to both 64 bit and 32 bit JDK installed? What ever may be the case, the java.exe seen by ant.bat should from the JDK. If the JRE's java.exe comes first in the path, that will be used to guess the JDK location.

将 'C:\Program Files (x86)\Java\jdk1.7.0_02\bin' 或 'C:\Program Files\Java\jdk1.7.0_02' 作为路径中的第一个参数.

Put 'C:\Program Files (x86)\Java\jdk1.7.0_02\bin' or 'C:\Program Files\Java\jdk1.7.0_02' as the first argument in the path.

进一步步骤:

您可以获取 ant -diagnostics 的输出并寻找有趣的键.(假设 Sun/Oracle JDK).

You can take output of ant -diagnostics and look for interesting keys. (assuming Sun/Oracle JDK).

 java.class.path 
 java.library.path
 sun.boot.library.path

(在我的例子中,tools.jar 出现在 java.class.path 中)

(in my case tools.jar appears in java.class.path)

这篇关于“无法找到tools.jar"跑蚂蚁的时候的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆