Maven- No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
This guide helps you to resolve “No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?” problem that you faced in your Eclipse IDE/Spring Tool Suite (STS) during running the Maven command i.e. clean install
/clean compile
.
These two command display the following error message:
[INFO] -------------------------------------------------------------
[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: 5.658 s
[INFO] Finished at: 2019-01-05T12:15:15+05:30
[INFO] ------------------------------------------------------------------------
Above error generally occurs when you try to build the project on JRE because by default Eclipse/STS configure the JRE automatically rather than JDK.
Solution
To compile/build the project using Maven in your favorite IDE like Eclipse/STS, you need to add the JDK in the Installed JREs because Maven needs the JDK to build/compile the project.
To add the JDK in your IDE follow the below steps:
Step 1: Go to your IDE Windows » Preferences » Java » Installed JREs
Step 2: Click on the Add… button, select Standard VM, proceed Next, browse your JDK Directory, and click on Finish.
Step 3: Checked the JDK that you have added and click on Apply and Close button.
Recompile/build your project again and I hope you will not face the same error again.