Selenium tips and tricks

How to solve No compiler is provided in this environment while running Maven build

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

 

No compiler is provided in this environment in Maven

 

 

Click on Java > Installed JRE’s

Here you will get JRE now we need to change it to JDK.

 

No compiler is provided in this environment in Maven

 

Now we need to add JDK > Click on Add > Select Standard VM

No compiler is provided in this environment in Maven

 

 

Browser JDK where it is located. Generally, you will get  JAVA in below location.

No compiler is provided in this environment in Maven

 

Now once JDK set you are done.

 

No compiler is provided in this environment in Maven

 

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
author-avatar

About Mukesh Otwani

I am Mukesh Otwani working professional in a beautiful city Bangalore India. I completed by BE from RGPV university Bhopal. I have passion towards automation testing since couple of years I started with Selenium then I got chance to work with other tools like Maven, Ant, Git, GitHub, Jenkins, Sikuli, Selenium Builder etc.

33 thoughts on “How to solve No compiler is provided in this environment while running Maven build

  1. DEVANAND DURG says:

    Thank you so much it worked

    1. Glad to see your comment…:)

  2. richa says:

    Addiing this plugin,generates error in the pom.xml file.

    1. Hi Richa,

      I hope that you are using Java 8?

  3. AlexB says:

    Great!!! fixed the issue

    1. Glad to hear from you 🙂

  4. Utkarsh Anand says:

    Thank you for making this info available. It solved my issue.

    1. Hi Utkarsh,

      You’re always welcome to ask your doubts…:)

  5. karthik says:

    thank you for this information, helped me to overcome issues in my maven build.

    1. Hi Karthik,

      Glad to hear from you.
      You’re always welcome to my blog…:)

  6. Alekhya Vandanapu says:

    Thanks a lot Its working

    1. Hi Alekhya,

      You’re welcome…
      Feel free to ask your doubts…:)

  7. 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

    1. Hi Jaffar,

      Kindly uninstall JDK 12 -> Restart system -> Then install JDK 8

  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

  9. kevin says:

    Thank you good human!

  10. Imtiyaz says:

    Thanks Mukesh. This helped a lot.

  11. Gaurav Kantrod says:

    Amazing and easy explanation.

    1. Thanks Gaurav 🙂 keep visiting and let me know if any help.

  12. Shakti Das says:

    Nice Blog Boss,Very clear and prescribed manner.

    1. Hi Shakti,

      Thanks for your comments.

  13. Andres says:

    Thanks a lot!!!

  14. NG says:

    thanks a lot.

  15. saurav kumar says:

    Thanks a lot Mukesh. I learns a lots from your website.keep it up.

    1. Thanks Saurav 🙂 Keep visiting.

  16. isub897 says:

    Solid bro. Most straight forward example I’ve seen. Cheers

    1. Thanks Mate 🙂

  17. 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

  18. nik says:

    you are GOD . Thank you

    1. Thanks a ton Nik 🙂 You made my day. PLease let me know if you need any help from my side.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.