在 Android SDK 中设置 JAVA_HOME

Setting JAVA_HOME at Android SDK(在 Android SDK 中设置 JAVA_HOME)
本文介绍了在 Android SDK 中设置 JAVA_HOME的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我与 JAVA_HOME 配置有一些冲突当我使用以下代码时 -

I have some conflicts with the JAVA_HOME configuration When I using the following code -

System.out.println(System.getenv("JAVA_HOME"));

我得到 - C:jdk1.6.0_23 这是正确的地方.但是,当我在 Android build.xml 上运行 Ant 命令时,我收到以下错误消息 -

I get - C:jdk1.6.0_23 which is the correct place. But, When I run Ant command on an Android build.xml, I got the following error message -

C:android-sdk-windows oolsantmain_rules.xml:361:找不到javac编译器;com.sun.tools.javac.Main 不上类路径.也许 JAVA_HOME 没有指向JDK.目前已设置到C:jdk1.6.0_23jre"

C:android-sdk-windows oolsantmain_rules.xml:361: 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:jdk1.6.0_23jre"

如何解决?

谢谢,

艾尔

推荐答案

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

To permanently set your JAVA_HOME Environment Variable under Windows to the JDK directory you've mentioned do the following:

  1. 单击开始,右键单击计算机并选择属性(您可以同时按住 windows 键并按下暂停/中断键).
  2. 点击左侧的高级系统设置.
  3. 点击底部的环境变量按钮.
  4. 单击系统变量"窗口下方的新建..."按钮.
  5. 输入以下内容:

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

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

  • 点击Ok、Ok、Ok,关闭你在步骤1中打开的系统控制面板
  • 关闭并重新打开命令提示符.
  • 如果您使用的是 Eclipse,请跳过上述步骤并执行以下操作:

    If you are using Eclipse then skip the steps above and do the following:

    1. 单击窗口"菜单并选择首选项".
    2. 展开左侧的Ant入口,点击Runtime
    3. 单击右侧 Classpath 选项卡中的 Global Entries.
    4. 点击添加外部 JAR...
    5. 导航到 C:jdk1.6.0_23lib 并选择 tools.jar 然后点击打开.
    6. 点击确定关闭首选项窗口.

    但是,在您的情况下,您最好的选择可能是简单地将 C:jdk1.6.0_23in 附加到您的 PATH 环境变量中,使用我上面的第一组说明作为粗略指导.

    In your situation however your best bet would probably be to simply append C:jdk1.6.0_23in to your PATH env var using my first set of instructions above as a rough guideline.

    这篇关于在 Android SDK 中设置 JAVA_HOME的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

    本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

    相关文档推荐

    How to find out locale-dependent text orientation in java?(如何在java中找出依赖于语言环境的文本方向?)
    Eclipse gets stuck when trying to launch Android app(Eclipse 在尝试启动 Android 应用程序时卡住了)
    Pinning a Java application using Launch4j to the Windows 7 taskbar(使用 Launch4j 将 Java 应用程序固定到 Windows 7 任务栏)
    ffmpeg executed from Java#39;s processbuilder does not return under windows 7(从 Java 的 processbuilder 执行的 ffmpeg 在 windows 7 下不返回)
    JavaExe and Java application as windows system service interactive to desktop(JavaExe 和 Java 应用程序作为与桌面交互的 Windows 系统服务)
    Windows 7 - System32 folder - java.exe(Windows 7 - System32 文件夹 - java.exe)