Search code examples
javaeclipseantjavac

Why is Eclipse adding /jre to my JAVA_HOME


A colleague installed a new application for me today and has managed to mangle my PATH and my java environments. I think I have the critical stuff back, but java build in Eclipse (via ant) does not work. I get the following error:

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:\Java\jdk\jre"

The really weird thing is that that is not what my JAV_HOME is set to!

H:\>echo %JAVA_HOME%
C:\Java\jdk

Where is the extra \jre coming from?

I have also added C:\Java\jdk\bin to my PATH variable, so javac is on the path:

H:\>javac
Usage: javac <options> <source files>
where possible options include:

The line in the build.xml which the stack trace points to is a simple javac ant command:

<javac source="${webapps.javac_target}" target="${webapps.javac_target}" debug="on" destdir="${classes}" srcdir="${src}">

The default Installed JRE has location C:\Java\jdk (and this is the one used by this project). Even the eclipse.ini ensures that Eclipse uses the same JDK with

-vm
C:\Java\jdk\bin\javaw.exe

Any ideas what I need to set to make this work again?


Solution

  • I thought that the Installed JREs was correct. I even downloaded a new JDK. In the end we discovered that it was pointing to the JDK root, not the JRE folder within. Changing that solved my problem