在 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:
- 单击开始,右键单击计算机并选择属性(您可以同时按住 windows 键并按下暂停/中断键).
- 点击左侧的高级系统设置.
- 点击底部的环境变量按钮.
- 单击系统变量"窗口下方的新建..."按钮.
输入以下内容:
- 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
如果您使用的是 Eclipse,请跳过上述步骤并执行以下操作:
If you are using Eclipse then skip the steps above and do the following:
- 单击窗口"菜单并选择首选项".
- 展开左侧的Ant入口,点击Runtime
- 单击右侧 Classpath 选项卡中的 Global Entries.
- 点击添加外部 JAR...
- 导航到 C:jdk1.6.0_23lib 并选择 tools.jar 然后点击打开.
- 点击确定关闭首选项窗口.
但是,在您的情况下,您最好的选择可能是简单地将 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.
相关文章