Maven error in Eclipse: No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?

When using Maven in Eclipse, it is possible to get an error related to the configuration of the JRE. Even if you have already configured Eclipse and you are correctly using a Java Virtual Machine to compile and execute your code, it can happen that, running a Maven goal (compile, install, etc.), you get an error message like this one:
              
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project xxx: 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                    
The solution is pretty easy. You can just select the correct execution environment in Eclise. Go to :Window > Preferences > Java > Installed JREs > Execution Environment and select the correct compatible JRE, according to the Java version you are using.
At that point, just right click on your project and do Maven > Update Project. You can also specify the JRE for a specific Maven Build. Go to Run > Run Configurations, select the Maven Build that you want to configure, and specify the JRE in the JRE tab.