2013-06-03 77 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

相關問題