2013-06-03 93 views
1

我知道这个问题已被多次询问,但没有一个答案似乎有效。JAVA_HOME没有指向JDK

简短版本: 我需要让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命令行

C:\Android\JDK 

我到处看看运行$env:$JAVA_HOME,似乎JAVA_HOME路径设置为:

C:\Android\JDK 

我也试图更新在Android中的build.xml文件,但没有奏效。我看着ant.bat文件,但这没有帮助。我真的对此感到不知所措。

这里是我的PATH:

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?

我确定还有一些,但我不记得我试过的所有东西,但我现在花了几个小时。

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

如果我遗漏了任何东西,我很抱歉。

任何帮助,将不胜感激。

+0

我知道JRE不是JDK,我试图让它识别我的JDK,我需要知道如何做到这一点。 – BlackHatSamurai

回答

0

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

0

尝试设置系统环境变量:

setx JAVA_HOME C:\Android\JDK 
+0

不幸的是,这并没有奏效。尽管谢谢你的回应。 – BlackHatSamurai