
In this article, I am going to discuss the frequently faced issue, which you might face while working with Maven. No compiler is provided in this environment in Maven will only come when you run the maven build the first time. In this case, we need to make certain changes that will fix your issue.
When you run the maven build through eclipse then you might get below error. If you try to read the error log it says clearly that no compiler is detected so in this we can change the JRE to JDK.
You will not get this error if you are running through Jenkins this only comes when running via Eclipse or CMD.
The error will be like
Error message for No compiler is provided in this environment in Maven
[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
Do not worry about this issue because it is just a small configuration change that you need to perform in order to make it work.
 I have a dedicated video on this.
Solution 1- for No compiler is provided in this environment in Maven
Click on Windows > Click on preferences
Click on Java > Installed JRE’s
Here you will get JRE now we need to change it to JDK.
Now we need to add JDK > Click on Add > Select Standard VM
Browser JDK where it is located. Generally, you will get  JAVA in below location.
Now once JDK set you are done.
Now you can run pom.xml file from Eclipse or through CMD and Run pom.xml file > Maven clean then Maven Install and Finally Maven build.
Solution 2- Using Maven compiler plugin
Using Maven compiler plugin we can provide JAVAC (Java Compiler) path, which will fix the issue.
You can open your pom.xml file and add below changes in pom.xml
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<verbose>true</verbose>
<fork>true</fork>
<executable>${JAVA_HOME}/bin/javac</executable>
</configuration>
</plugin>
Where JAVA_HOME is the path variable which we have set earlier while installing Java.
Note- I personally prefer the second solutions which work across multiple platforms.
You can like our Facebook Page for more updates | Learn Automation Page |
Join our Facebook group for any query | Selenium Group Discussion |
Awesome, thank you for the outstanding guide. My school library’s lab environment had us running Maven using a JRE, luckily they had a SDK ready for us to set as JAVA_HOME.
Nice I am glad it helped.
Thank you so much it worked
Glad to see your comment…:)
Addiing this plugin,generates error in the pom.xml file.
Hi Richa,
I hope that you are using Java 8?
Great!!! fixed the issue
Glad to hear from you 🙂
Thank you for making this info available. It solved my issue.
Hi Utkarsh,
You’re always welcome to ask your doubts…:)
thank you for this information, helped me to overcome issues in my maven build.
Hi Karthik,
Glad to hear from you.
You’re always welcome to my blog…:)
Thanks a lot Its working
Hi Alekhya,
You’re welcome…
Feel free to ask your doubts…:)
Hi mukesh,
I got this error “Target is not a JDK Root. System library was not found.”. I am using eclipse neon and jdk version is 12.0.2.
C:\Program Files\Java\jdk-12.0.2 -> this is my path of JDK
Regards,
Jaffar
Hi Jaffar,
Kindly uninstall JDK 12 -> Restart system -> Then install JDK 8
Hi Saurav,
In that case you can use below plugin in POM.xml file
Note- Change the path accordingly.
maven-compiler-plugin
3.3
true
C:\Program Files\Java\jdk_1.8\bin\javac.exe
Thank you good human!
Thanks Mukesh. This helped a lot.
Thanks Imtiyaz
Amazing and easy explanation.
Thanks Gaurav 🙂 keep visiting and let me know if any help.
Nice Blog Boss,Very clear and prescribed manner.
Hi Shakti,
Thanks for your comments.
Thanks a lot!!!
Welcome Andres.
thanks a lot.
Welcome mate.
Thanks a lot Mukesh. I learns a lots from your website.keep it up.
Thanks Saurav 🙂 Keep visiting.
Solid bro. Most straight forward example I’ve seen. Cheers
Thanks Mate 🙂
Hi Mukesh,
Can you please provide me the Folder Structure in selenium using Maven and without using Maven.
and also GIT commands.
Regards,
Kanchana
you are GOD . Thank you
Thanks a ton Nik 🙂 You made my day. PLease let me know if you need any help from my side.