Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
570 views
in Technique[技术] by (71.8m points)

windows - Setting JAVA_HOME at Android SDK

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

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

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-windowsoolsantmain_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"

How it can be resolved?

Thanks,

Eyal

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

  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 
    
  6. Click Ok, Ok, Ok, and close the system control panel you opened in step 1
  7. Close and re-open your command prompt.

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

  1. Click on the Window menu and choose Preferences.
  2. Expand the Ant entry on the left and click on Runtime
  3. Click on Global Entries in the Classpath tab on the right.
  4. Click Add External JARs...
  5. Navigate to C:jdk1.6.0_23lib and select tools.jar then click open.
  6. Hit ok to Close the preferences Window.

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...