2

When I am trying to debug my code then I am getting the following error:

Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.0.2

[INFO] ------------------------------------------------------------------------
[ERROR] **Failed to execute goal org.apache.maven.plugins:maven-compiler-**plugin:2.0.2:compile (default-compile) on project napier-am: Compilation failure
Unable to locate the Javac Compiler in:
  C:\Program Files (x86)\Java\jre6\..\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.
-> [Help 1]
[ERROR] 
[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] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
2
  • 1
    What have you tried regarding Please ensure you are using JDK 1.4 or above and not a JRE? Commented Apr 29, 2015 at 9:50
  • @Jeet Singh Configure the Build Path for the Project and point the Java Libraries to JDK Commented Apr 29, 2015 at 9:50

4 Answers 4

1

Maven uses JAVA_HOME to access Java's location on the machine. In Your situation You point it to JRE not JDK. Set properly JAVA_HOME environment variable and it will work.

If You want to have different location/version used for Maven only You can edit mvn.bat file with something like this.

set JAVA_HOME=<path_to_other_jdk>
Sign up to request clarification or add additional context in comments.

Comments

1

Your JAVA_HOME path is not set. You need to set it as C:\Program Files\Java\jdk <version>

4 Comments

My - JAVA_HOME- C:\Program Files (x86)\Java\jdk1.6.0_25 I am new in Maven. When I am trying to build then its showing build success but at the time of debugging giving above mentioned error
@GwynEvans it was my mistake. I edited it accordingly :)
Fair enough, now deleted. To the OP, using a JRE will let you run things, but you need a JDK to compile them. Also, that's not a debug message, Maven is trying to compile something, so don't assume you've built it already.
Yeah Thanks. That was my mistake. Now I am able to build it
0

Everything is said in the exception:

Unable to locate the Javac Compiler in: C:\Program Files (x86)\Java\jre6..\lib\tools.jar

Your maven task is trying to "compile" something, but can't find the Java compiler (JDK=Java Development Kit).

Please ensure you are using JDK 1.4 or above and not a JRE.

Instead it finds a JRE=Java Runtime Environment (which is used for running java programs, not compiling them).

you can change the location of your Java installation by setting the JAVA_HOME environment variable

You need to have a valid JDK version installed and your JAVA_HOME environment variable must point to this JDK folder.

Comments

0

Yeah Thanks for the clue.. Everyone is correct. In my JDK version tools.jar was not available thats why I was getting this problem its not finding tools.jar, While JAVA_HOME varible is configured correctly. Need to focus on only Tools.jar so that installed again java version (i am using java 6) Now come on project--> go thru the build path and Make sure---- click on

installed jre edit jre home =C:\Program Files (x86)\Java\jdk1.6.0_25

give path accordingly for which Your OS is compatible

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.