JAVA_HOME没有指向JDK

时间:2013-06-03 22:55:45

标签: java android windows ant automation

我知道这个问题已被问过几次,但没有一个答案似乎有效。

简短版本 我需要让Ant指向我的JDK而不是我的JRE。

长版:

我的问题是我正在尝试进行一些Android自动化,而我正在使用Powershell脚本启动它。 Powershell脚本运行后,JUnit测试通过Ant构建运行。但是当我构建时,我得到了这个错误:

BUILD FAILED
C:\Android\adt-bundle-windows\sdk\tools\ant\build.xml:598: The following error occurred while executing this line:
C:\Android\adt-bundle-windows\sdk\tools\ant\build.xml:713: The following error occurred while executing this line:
C:\Android\adt-bundle-windows\sdk\tools\ant\build.xml:727: Unable to find a javac compiler;
com.sun.tools.javac.Main is not on the classpath.
Perhaps JAVA_HOME does not point to the JDK.
It is currently set to "C:\Android\Jre7"

我认为问题可能是我没有正确设置JAVA_HOME变量,所以我检查了:

以下是从我的命令行运行的JAVA_HOME的输出:

C:\Android\JDK

以下是我在命令行中运行set时的输出:

C:\Android\JDK

以下是从Powershell命令行运行$env:$JAVA_HOME时的输出

C:\Android\JDK

我看,似乎JAVA_HOME路径设置为:

C:\Android\JDK

我还尝试更新Android中的build.xml文件,但这不起作用。我查看了ant.bat文件,但这没有帮助。我真的很茫然。

这是我的路径:

PATH=C:\Android\adt-bundle-windows\sdk\platform-tools;C:\Program Files\Common Files\Microsoft Shared\Microsoft Online Services;C:\Program Files (x86)\Common Fil
es\Microsoft Shared\Microsoft Online Services;C:\windows\system32;C:\windows;C:\
windows\System32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Microsoft\Web Platform Installer\;C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\;C:\Program Files (x86)\Windows Kits\8.0\Windows Performance Toolkit\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;C:\Android\JDK\bin;C:\Android\apache-ant-1.9.1\bin;C:\Android\android-ndk-r8e;C:\Android\adt-bundle-windows\sdk\tools;C\perl\x86\bin;C:\Android\JDK\bin;

以下是我查看并尝试过的链接列表:

Java ant Eclipse run error

Ant build not working: unable to find a javac compiler

Java ant Eclipse run error

Why does ANT tell me that JAVA_HOME is wrong when it is not?

我确信还有更多,但我记不起我尝试过的一切,但我现在花了几个小时。

我在戴尔PC上运行Windows 8。我安装了JDK 7,以及Android Eclipse和SDK。我正在使用Ant 1.9.1

如果我遗漏了什么,我很抱歉。

任何帮助将不胜感激。

2 个答案:

答案 0 :(得分:0)

尝试设置系统环境变量:

setx JAVA_HOME C:\Android\JDK

答案 1 :(得分:0)

为了解决我的问题,我最终不得不卸载&重新安装JDK,确保不安装JDK附带的JRE(第二个版本,'独立'JRE,而不是JDK中包含的JRE)。

我还必须重新安装Ant。

相关问题