简体   繁体   中英

JAVA_HOME not pointed at JDK

I know that this question has been asked several times, but none of the answers seem to have worked.

Short version: I need to get Ant to point to my JDK rather than my JRE.

Long version:

My issue is that I'm trying to do some Android automation, and I am using a Powershell script to kick this off. Once the Powershell script runs, JUnit tests are run via an Ant build. But when I build I get this error:

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"

I thought the problem might be that I didn't set the JAVA_HOME variable correctly, so I checked:

Here is the output of my JAVA_HOME run from my command line:

C:\Android\JDK

Here is the output when I run set in command line:

C:\Android\JDK

Here is the output when I run $env:$JAVA_HOME from the Powershell command line

C:\Android\JDK

Everywhere I look, it seems that the JAVA_HOME path is set to:

C:\Android\JDK

I have also tried to update the build.xml file in Android, but that didn't work. I looked at the ant.bat file, but that didn't help. I'm really at a loss on this.

Here is my 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;

Here is a list of the links I have looked at and tried:

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?

I'm sure there are a couple more, but I can't remember everything I've tried, but I've spent a couple hours on this now.

I am running Windows 8, on a Dell PC. I have JDK 7 installed, along with the Android Eclipse and SDK. I am using Ant 1.9.1

If I left anything out, I'm sorry.

Any help would be appreciated.

尝试设置系统环境变量:

setx JAVA_HOME C:\Android\JDK

To solve my issue, I ended up having to uninstall & reinstall the JDK, making sure NOT to install the JRE that is included with the JDK (the second version, the 'stand-alone' JRE, not the JRE included IN the JDK).

I also had to reinstall Ant.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM