Maven, unable to locate javac compiler

Hi,

I am new in this site and also newbee in maven, so if any mistake, pls cosider it.

Sub: I am trying to run pom.xml file through command line. And even I set the JAVA_HOME as per the project requirement(JDK 1.6), and set this to maven path. For other project this is working fine but when I run, got below error:
Unable to rectify it, pls help urgently.

Thanks
Sarfaraz

[ERROR]

Mojo:

org.apache.maven.plugins:maven-compiler-plugin:2.0.2:compile

FAILED for project:

com.fusionone:f1core:jar:1.97

Reason:

Unable to locate the Javac Compiler in:
C:\Program Files\Java\jre1.6.0_07\..\lib\tools.jar
Please ensure you are using JDK 1.4 or above and
not a JRE (the com.sun.tools.javac.Main class is required).
In most cases you can change the location of your Java
installation by setting the JAVA_HOME environment variable.

Reply echo %JAVA_HOME%

Hi,

Thanks for early reply.

When I echoed at command prompt, it has given.

C:\Program Files\Java\jdk1.6.0_10

You can see in below message, it is searching in tools.jar, but I think, for compilation it has to go to bin folder. am I right?. And I set bin into 'path' already.
Unable to locate the Javac Compiler in:
C:\Program Files\Java\jre1.6.0_07\..\lib\tools.jar
Thanks,
Sarfaraz

The bottom line to all this is that Maven is looking in your JRE directory when you want it to look in your JDK directory. That means you've got something set up in your environment that you haven't mentioned yet.

Please describe how you are starting the Maven build (we'll need to make sure you're starting it with the JDK's runtime, not the JRE). Also, post your maven-compiler-plugin element from the pom.

eclipse solution

I got the same, when running maven in eclipse

Unable to locate the Javac Compiler in:
C:\Program Files\Java\jre1.6.0_07\..\lib\tools.jar
Please ensure you are using JDK 1.4 or above and
not a JRE (the com.sun.tools.javac.Main class is required).
In most cases you can change the location of your Java
installation by setting the JAVA_HOME environment variable.

What I discovered is that the JRE set from Eclipse was pointing to the "Program Files\Java\Jre...", the one without jdk.The solution was to change the JRE to the "...SDK\jdk\jre..." the one contained in the JDK installation.

What I discovered is that the JRE set from Eclipse was pointing to the "Program Files\Java\Jre...", the one without jdk.The solution was to change the JRE to the "...SDK\jdk\jre..." the one contained in the JDK installation.