1

When I try to maven run the test code, this error pops up:

[INFO] Finished at: Wed May 21 17:17:47 CST 2014 [INFO] Final Memory: 12M/61M 
[INFO]------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.0:compile (default-compile) on project java-checks: Compilation failure 
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK? 
[ERROR] -> [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

I run Maven from Eclipse and have set a JDK in Preference > Java > Installed JREs but I still get that error.

What are the solutions to it?

André Stannek
  • 7,773
  • 31
  • 52
  • 3
    A little more context would help. How are you running Maven? How did you "configure the JDK"? – André Stannek May 21 '14 at 09:32
  • Through the preference > java > installed jres > chek on idk file – user3659013 May 21 '14 at 09:44
  • Are you running this through an IDE, or through the console? – carlspring May 21 '14 at 09:44
  • possible duplicate of [No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?](http://stackoverflow.com/questions/19655184/no-compiler-is-provided-in-this-environment-perhaps-you-are-running-on-a-jre-ra) – oberlies May 21 '14 at 14:22
  • Searching for `Perhaps you are running on a JRE rather than a JDK?` on SO gives a solution to your problem. Please stop wasting people's time by asking duplicate questions. – oberlies May 21 '14 at 14:24

2 Answers2

0

You haven't set your JAVA_HOME variable correctly, or $JAVA_HOME/bin (%JAVA_HOME%\bin) is not on your PATH variable (I would advise you put this at the beginning of the PATH environment variable).

carlspring
  • 31,231
  • 29
  • 115
  • 197
0

It's not enough to set a JDK in "installed JREs" when you run Maven from Eclipse. Eclipse itself also has to run in a JDK.

To make sure of that, edit the eclipse.ini in your Eclipse folder. Add somtehing like

-vm
C:/Program Files/Java/jdk1.7.0_51/bin/javaw.exe

of course with the right path to your JDK.

André Stannek
  • 7,773
  • 31
  • 52