問(wèn)題描述
我與 JAVA_HOME
配置有一些沖突當(dāng)我使用以下代碼時(shí) -
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
這是正確的地方.但是,當(dāng)我在 Android build.xml 上運(yùn)行 Ant 命令時(shí),我收到以下錯(cuò)誤消息 -
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:找不到j(luò)avac編譯器;com.sun.tools.javac.Main 不上類(lèi)路徑.也許 JAVA_HOME 沒(méi)有指向JDK.目前已設(shè)置到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 環(huán)境變量永久設(shè)置為您提到的 JDK 目錄,請(qǐng)執(zhí)行以下操作:
To permanently set your JAVA_HOME Environment Variable under Windows to the JDK directory you've mentioned do the following:
- 單擊開(kāi)始,右鍵單擊計(jì)算機(jī)并選擇屬性(您可以同時(shí)按住 windows 鍵并按下暫停/中斷鍵).
- 點(diǎn)擊左側(cè)的高級(jí)系統(tǒng)設(shè)置.
- 點(diǎn)擊底部的環(huán)境變量按鈕.
- 單擊系統(tǒng)變量"窗口下方的新建..."按鈕.
輸入以下內(nèi)容:
- 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,請(qǐng)?zhí)^(guò)上述步驟并執(zhí)行以下操作:
If you are using Eclipse then skip the steps above and do the following:
- 單擊窗口"菜單并選擇首選項(xiàng)".
- 展開(kāi)左側(cè)的Ant入口,點(diǎn)擊Runtime
- 單擊右側(cè) Classpath 選項(xiàng)卡中的 Global Entries.
- 點(diǎn)擊添加外部 JAR...
- 導(dǎo)航到 C:jdk1.6.0_23lib 并選擇 tools.jar 然后點(diǎn)擊打開(kāi).
- 點(diǎn)擊確定關(guān)閉首選項(xiàng)窗口.
但是,在您的情況下,您最好的選擇可能是簡(jiǎn)單地將 C:jdk1.6.0_23in 附加到您的 PATH 環(huán)境變量中,使用我上面的第一組說(shuō)明作為粗略指導(dǎo).
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.
這篇關(guān)于在 Android SDK 中設(shè)置 JAVA_HOME的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!