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-windows\tools\ant\main_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_23\jre"
How it can be resolved?
Thanks,
Eyal
Solution 1:
To permanently set your JAVA_HOME Environment Variable under Windows to the JDK directory you've mentioned do the following:
- 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\
- Click Ok, Ok, Ok, and close the system control panel you opened in step 1
- Close and re-open your command prompt.
If you are using Eclipse then skip the steps above and do the following:
- Click on the Window menu and choose Preferences.
- Expand the Ant entry on the left and click on Runtime
- Click on Global Entries in the Classpath tab on the right.
- Click Add External JARs...
- Navigate to C:\jdk1.6.0_23\lib and select tools.jar then click open.
- Hit ok to Close the preferences Window.
In your situation however your best bet would probably be to simply append C:\jdk1.6.0_23\bin to your PATH env var using my first set of instructions above as a rough guideline.
Solution 2:
- Copy c:\windows\system32\java.exe to c:\windows\syswow64
- Set JAVA_HOME to path, use
/
instead of\