問題描述
我與 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.
這篇關于在 Android SDK 中設置 JAVA_HOME的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!