I'm compiling a project in Eclipse using m2eclipse. I set the JDK path in Eclipse like this:
Windows-->preferences-->installed jres--> jdk1.7.xx path
But this is showing an error
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.424s
[INFO] Finished at: Tue Oct 29 15:21:01 IST 2013
[INFO] Final Memory: 5M/15M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler- plugin:3.1:compile (default-compile) on project TEST-WEB: Compilation failure
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
i faced the same issue, the mistake i made was i added jre path only in the path var,not jdk path .When jdk path was added to path and build the maven project its working perfect .Thanks all
I faced the same issue while trying to build a jar file of my project application using
mvn clean install
, though the application was working fine while running from Eclipse.The issue was, indeed too naive, that I had not set the JAVA_HOME environment variable. All I had to do is set JAVA_HOME environment variable to JDK directory, make sure it is not till "\bin" and without semi-colon ";".
How I understood it is as:
The application worked fine in Eclipse as JRE System Library was referring to JRE inside the JDK folder instead of external JRE folder without JDK. [As explained very well in other answers]
This configuration does not apply to maven command that we run on command prompt. It will still look for JAVA_HOME variable to access the JRE System library and when it is not found it refers to external JRE folder without JDK.
I did the following change and it worked for me.Hope it helps someone.
I tried most of the answers without success. What worked for me was (after following https://stackoverflow.com/a/21279068/2408893):
I got same issue and i just add
JAVA_HOME
to environment variables.JAVA_HOME
open command prompt from project directory and runmvn clean install
(don't use intellij terminal).There are several answers regarding this question but all are related to right path configuration of JDK, but with JRE only we can solve this problem.
We just need to make use of deployment assembly to configure the path of packaged war file of the Java EE Project and then re-run the maven-install.
Steps to make use of deployment assembly:
Right click on the Jave EE project --> click on Properties --> click on Deployment Assembly
Click on Add button --> Click on Archives from the File System --> Click on next --> Click on Add --> Go to the .m2\respository directory and search for the war file generated --> Select war file --> Click on Open button --> Click on Apply --> OK
Right click on the project --> Click on Maven Install under Run As
This will build your project successfully, without any compiler error.
Hope this solves the problem without JDK.