Unable to find a javac Perhaps JAVA_HOME does not point to the JDK


If you have imported an existing project in eclipse , especially when you want to setup the test environment on a new machine you sometimes see this error "Unable to find a javac; Perhaps JAVA_HOME does not point to the JDK"

Unable to find a javac; Perhaps JAVA_HOME does not point to the JDK


This is a common error that I have seen a couple of times hence the solution:

Solution that did not work :
Select the JRE by going to the Window-->Preferences-->JAVA-->Editor-->Installed JRE

Solution that worked: 
Simple just download tools.jar 
and add tools.jar file in window->preferences->ant-> runtime-> Global Entries
once done you will be all set!

Here are some screenshots:
C:\drftpd>ant
Unable to locate tools.jar. Expected to find it in C:\Program Files\Java\jre6\li
b\tools.jar
Buildfile: build.xml

compile:
[echo] Compiling 1.4 compatible slave files
[javac] Compiling 63 source files to C:\drftpd\classes

BUILD FAILED
C:\drftpd\build.xml:140: 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:\Program Files\Java\jre6"

Total time: 3 seconds


Even though the JAVA_HOME is set to C:\Program Files\Java\jdk1.6.0_10\bin as you can see here:
Image
Copy C:\Program Files\Java\jdk1.6.0_10\lib\tools.jar to C:\Program Files\Java\jre6\lib\ext

Comments

Popular posts from this blog

Software Testing @ Microsoft

Trim / Remove spaces in Xpath?