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 |
Eduardo Rodrigues says
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.
Mukesh Otwani says
Nice I am glad it helped.
DEVANAND DURG says
Thank you so much it worked
Mukesh Otwani says
Glad to see your comment…:)
richa says
Addiing this plugin,generates error in the pom.xml file.
Mukesh Otwani says
Hi Richa,
I hope that you are using Java 8?
AlexB says
Great!!! fixed the issue
Mukesh Otwani says
Glad to hear from you 🙂
Utkarsh Anand says
Thank you for making this info available. It solved my issue.
Mukesh Otwani says
Hi Utkarsh,
You’re always welcome to ask your doubts…:)
karthik says
thank you for this information, helped me to overcome issues in my maven build.
Mukesh Otwani says
Hi Karthik,
Glad to hear from you.
You’re always welcome to my blog…:)
Alekhya Vandanapu says
Thanks a lot Its working
Mukesh Otwani says
Hi Alekhya,
You’re welcome…
Feel free to ask your doubts…:)
jaffar says
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
Mukesh Otwani says
Hi Jaffar,
Kindly uninstall JDK 12 -> Restart system -> Then install JDK 8
Mukesh Otwani says
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
kevin says
Thank you good human!
Imtiyaz says
Thanks Mukesh. This helped a lot.
Mukesh Otwani says
Thanks Imtiyaz
Gaurav Kantrod says
Amazing and easy explanation.
Mukesh Otwani says
Thanks Gaurav 🙂 keep visiting and let me know if any help.
Shakti Das says
Nice Blog Boss,Very clear and prescribed manner.
Mukesh Otwani says
Hi Shakti,
Thanks for your comments.
Andres says
Thanks a lot!!!
Mukesh Otwani says
Welcome Andres.
NG says
thanks a lot.
Mukesh Otwani says
Welcome mate.
saurav kumar says
Thanks a lot Mukesh. I learns a lots from your website.keep it up.
Mukesh Otwani says
Thanks Saurav 🙂 Keep visiting.
isub897 says
Solid bro. Most straight forward example I’ve seen. Cheers
Mukesh Otwani says
Thanks Mate 🙂
Kanchana says
Hi Mukesh,
Can you please provide me the Folder Structure in selenium using Maven and without using Maven.
and also GIT commands.
Regards,
Kanchana
nik says
you are GOD . Thank you
Mukesh Otwani says
Thanks a ton Nik 🙂 You made my day. PLease let me know if you need any help from my side.