Wednesday, August 30, 2017

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

Have you came across below Maven error while running maven install or build command through Eclipse.


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

This error message clearly tells us two things:
  • "No compiler is provided in this environment.": While running maven install or build command for our project, it couldn't detect the required compiler due to some missing/incorrect Eclipse configuration. 
  • "Perhaps you are running on a JRE rather than a JDK?": It states the probable root cause of the issue i.e maybe JRE is added to the build path of the newly created java project. 

This article is a How To Guide to show the steps with screenshots to fix the above issue.

Resolution


To resolve this issue, one need to make some Eclipse configuration changes so that the JDK is added to the build path of the newly created java project.

Please follow the below steps to make this required changes:

Step 1: From Eclipse IDE, go into Window > Preferences > Java > Installed JREs and then check the installed JREs. We should have an entry for JDK there. If it is there select required checkbox otherwise follow step 2 to add the required version JDK.

Below Preferences dialog box would appear as soon as one choose  Window Preferences option


Step 2: Click on the Add button > select Standard VM > Next > Browse JDK by clicking on Directory button > Click on Finish



Resulting dialog box after selecting Standard VM option and clicking on Next button..


Step 3 : Verify the Java Build Path for your java project whether it's pointing to the JDK or not
Select and Right-Click on the required java project  > click on Properties > select Java Build Path option present in the left pan of Properties dialog box > under Libraries tab check the JRE System Library[..], inside the bracket, it should be pointing to JDK like JRE System Library[jdk1.8.0_131]


That's it, we are done. Now you will not get "No compiler is provided in this environment." error while running maven install or build. If you have any suggestion or have any question do let me know in the comment box. Happy Learning!!

2 comments: