Thursday, 27 June 2013

Unable to locate Compiler Error in Eclipse and Maven

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project test-commons: Compilation failure
[ERROR] Unable to locate the Javac Compiler in:
[ERROR] C:\Program Files\Java\jre7\..\lib\tools.jar
[ERROR] Please ensure you are using JDK 1.4 or above and
[ERROR] not a JRE (the class is required).
[ERROR] In most cases you can change the location of your Java
[ERROR] installation by setting the JAVA_HOME environment variable.
[ERROR] -> [Help 1]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn  -rf :test
This error occurs because maven uses java compiler classes available in tools.jar to compile java files. Tools.jar is part of jdk , not the jre. So if you have configured only jre in eclipse , you will get this error. To resolve this , go to prefreneces and select java and configure jre.
Now edit this independent JRE and give path to JDK.

So , to run maven in eclipse , you should have path to jdk , not individual installed JRE.

Post Comments and Suggestions !!!