【问题标题】:JAVA_HOME conflict with Android SDKJAVA_HOME 与 Android SDK 冲突
【发布时间】:2013-07-18 20:58:24
【问题描述】:

我在尝试构建我的 Android 应用程序时收到以下错误:

Perhaps JAVA_HOME does not point to the JDK.
It is currently set to "C:\Program Files (x86)\Java\jre7"

但是系统环境变量JAVA_HOME实际上设置为“C:\Program Files\Java\jdk1.7.0_25”

对于 JAVA_HOME,我们有两个不同的值。

这种冲突从何而来?

【问题讨论】:

  • 它有很多赞成票的答案。可能 OP 忘记接受了。
  • 6 票的答案是我在考虑发布这个问题之前所做的。我的问题更准确:SDK读取的值来自哪里?
  • 试过将 JDK 路径设置为 java_home 吗?
  • 您如何构建您的应用程序(eclipse/ant 脚本/其他),这样 JAVA_HOME 没有指向正确的位置?

标签: android java android-2.2-froyo


【解决方案1】:

要将 Windows 下的 JAVA_HOME 环境变量永久设置为您提到的 JDK 目录,请执行以下操作:

Click Start, right click on Computer and select properties (you can also hold down the windows key and press the pause/break key).
Click on Advanced system settings on the left.
Click the Environment Variables button on the bottom.
Click the New... button below the System variables window.

Enter the following:

    Variable name: JAVA_HOME
    Variable value: C:\jdk1.6.0_23\ 

Click Ok, Ok, Ok, and close the system control panel you opened in step 1
Close and re-open your command prompt.

如果您使用的是 Eclipse,请跳过上述步骤并执行以下操作:

Click on the Window menu and choose Preferences.
Expand the Ant entry on the left and click on Runtime
Click on Global Entries in the Classpath tab on the right.
Click Add External JARs...
Navigate to C:\jdk1.6.0_23\lib and select tools.jar then click open.
Hit ok to Close the preferences Window.

但是,在您的情况下,您最好的选择可能是使用我上面的第一组说明作为粗略指南,将 C:\jdk1.6.0_23\bin 简单地附加到您的 PATH env var。

【讨论】:

  • 请回答问题
【解决方案2】:

您可以通过右键单击我的计算机然后高级系统设置来设置环境变量。您应该看到 Envirnment Variables 按钮单击它并将位置添加到 JDK。我注意到您当前将其指向 JRE。

【讨论】:

  • 系统上的JAVA_HOME其实是指向JDK的,路径正确。我不知道 SDK 从哪里得到 JAVA_HOME 错误值。这就是问题所在。
猜你喜欢
  • 2018-09-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-01-12
  • 2019-08-10
  • 2020-03-12
  • 2013-07-19
  • 1970-01-01
相关资源
最近更新 更多