score:171

Accepted answer

go to window → preferences → java → installed jres.

and see if there is an entry pointing to your jdk path, and if not, click on edit button and put the path you configured your java_home environment.

score:-1

i had a problem with eclipse neon where the workspace default did not actually change even though i added the correct location under preferences->java->installed jres. this was in a new workspace i created to work on a code branch; it was originally set to the jre location rather than the jdk. yet even after changing the preferences, i could build with the command line, yet building in eclipse produced the no compiler error. please see

maven package compilation error

for my answer on which eclipse configuration file(s) had to be manually edited to make eclipse recognize the correct workspace default. i still have no idea why the preferences setting did not carry through to the new workspace's configuration.

score:0

  1. uninstall older java(jdk/jre) from the system( keep one (latest) java version), also remove if any old java jre/jdk entries in environment variables path/classpath
  2. eclipse->window->preferences->installed jres->add/edit jdk from the latest installation
  3. eclipse->window->preferences->installed jres->execution environment->select the desired java version on left and click the check box on right
  4. if you are using maven include the following tag in pom.xml (update versions as needed) inside plugins tag.

    <plugin>  
            <groupid>org.apache.maven.plugins</groupid>
            <artifactid>maven-compiler-plugin</artifactid>
            <version>3.1</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
    
  5. right click on eclipse project maven - > update project

score:0

for me (on windows 10), i was getting the error "no compiler is provided in this environment" at the windows command prompt when i ran mvn install. the fix was changing the java_home environment variable to point to my jdk (c:\program files\java\jdk1.8.0_101); previously it had pointed to the jre.

and to get eclipse to use the new jdk, i edited eclipse.ini in my eclipse distribution and changed the line for -vm to c:\program files\java\jdk1.8.0_101\bin.

score:0

check java version in pom.xml and jre version in eclipse->window->preferences->installed jres. in my case pom.xml has different version(it had 1.8 while eclipse using 1.7). fixing the version in pom.xml to 1.7 worked.

score:0

if you are working outside of eclipse in the command window
make sure you have the right java_home and that that directory contains the compiler by entering the following command in the command window:

dir %java_home%\bin\javac.*

score:0

1.go to windows-->preferences-->java-->installed jres-->execution environments

2.select the java version you are using currently in the "execution environments" box. so that in the "compatible jres" box, you are able to see as "jre1.8.0_102[perfect match]"(if your java version is 1.8). then try to build using maven.

score:0

maven requires jdk to compile. in eclipse you need to change/ replace your jre to the jdk path that your java_home points to. navigate to window > preferences > java > installed jres.

make sure that the maven-compiler-plugin in you pom.xml has the source and target of the java version in your java_home

http://learn-automation.com/maven-no-compiler-is-provided-in-this-environment-selenium/

score:0

make sure you have %java_home% set by typing echo %java_home% in command prompt. if you don't have that set, then you need to go add your java path to window's environmental variables.

score:0

i resolved this issue by providing java_home in my enviroment variables and restarted intellij

score:0

you can follow any of one from given below.

  1. project--properties--java build path--jre system library--edit--add library path as jdk
  2. window preference--java--installed jre--jre system library--add library and provide path to jdk folder
  3. you will have to instruct eclipse to use jdk as build/compile source in some ways if it's configured to point to jre instead for default compiler

score:0

if none of the above helped still you are facing the same issue means you may have misconfigurations in your custom run/debug configurations.

in my case i am using a custom maven run configuration. there the jre is pointed earlier. once i changed it to jrk it worked as expected.
enter image description here

score:1

in my case, i had created a run configuration and whenever i tried to run it, the error would be displayed. after searching on some websites, i edited the run configuration and under jre tab, selected the runtime jre as 'workspace default jre' which i had already configured to point to my local java jdk installation (ex. c:\program files (x86)\java\jdk1.8.0_51). this solved my issue. maybe it helps someone out there.

score:1

was getting the same problem, pointed java to bin folder in eclipse using: windows > preferences > java > installed jres > remove any existing jre and point it to your java bin folder (mainly under c:\program files\java\jdk1.8.x_xx).

then run maven install it should work.

score:1

to check what your maven uses, open a command line and type:

mvn –version

verify that java_home refers to a jdk home and not a jre

on windows:

go to system properties -> advanced system settings -> advanced -> environment variable and on the system variables section select the java_home variable and click on edit fill the form with the following variable name: java_home variable value:

on unix:

export java_home=<absolute_path_to_jdk>

see this link

score:2

please check if you have the following entries in the element of your pom.xml especially the jdk.version because switching to an installed jre did not fix me the similar error.

<properties>
    <jdk.version>1.7</jdk.version>
    <spring.version>4.1.1.release</spring.version>
    <jstl.version>1.2</jstl.version>
    <junit.version>4.11</junit.version>
</properties>

score:2

if someone is running eclipse in ubuntu and have this problem i have found the answer by following these steps:

  1. eclipse->window->preference.
  2. select installed jres->add
  3. select standardvm.
  4. jre home: press [directory..] button.
  5. choose your java (my problem was my eclipse was running with java8 and my vm were with java7), in my case java8 was installed in usr/local/jvm/java-8-oracle.
  6. press finish.
  7. then press installed jres arrow so you can see the other options.
  8. go to execution environment.
  9. select javase-1.6 on left and in the right (the compatible jre) you have to choose the java you have just installed( in my case java-8-oracle). you have to do this steps with javase1.8.
  10. click ok and restart eclipse.

score:2

i was getting the same error when trying to execute a maven build within eclipse in a newly installed eclipse neon (for jee devs) installation, on windows 10 with jdk 8 and jre 8 installed.

i had tried specifying tools.jar as an external lib, as well as setting the jdk as the -vm in eclipse. neither of these things worked.

selecting the jdk as the default execution env as mentioned above did the trick..

  1. eclipse->window->preference->java->installed jres->execution environments.
  2. select javase-1.8
  3. check jdk1.8 in "compatible jres".

the text above the compatible jres listbox in step 3 says "a default jre can be specified by checking it"

note: i also have the maven compiler plugin explicitly listing 1.8 in the pom

    <plugin>  
        <groupid>org.apache.maven.plugins</groupid>
        <artifactid>maven-compiler-plugin</artifactid>
        <version>3.1</version>
        <configuration>
            <source>1.8</source>
            <target>1.8</target>
        </configuration>
    </plugin>

score:2

installed jre in my case i solved the problem by removing duplicates of names, i kept only one with the name: jdk.1.8.0_101

score:3

follow : windows --> preferences --> java ---> installed jres

sampleimage

click on "search.."

navigate to c drive ---> program files

sample image 2

eclipse will find all the jre's and jdk's --> select one of the jdk and select apply

score:4

i also faced similar error when i was working with jdk1.8_92. for me, i found tools.jar was missing in my jdk folder. since i was running in console, i couldn't try the options of eclipse suggested by others..

i installed jdk-8u92-windows-x64. after i tried all options, i observed that tools.jar was missing in jdk1.8.0_92/lib folder. i copied tools.jar from my older version of java. then it was able to compile.

score:6

when i was runing mvn compile, i was getting below error in console:

[info] changes detected - recompiling the module!
[warning] file encoding has not been set, using platform encoding cp1252, i.e. build is platform dependent!
[info] compiling 1087 source files to c:\code\devvnextcomplete\development_vnext\source\jars\target\classes
[info] -------------------------------------------------------------
[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

[resolution]

i had added, the java_home variable in my environment variables and then it worked.

enter image description here

score:8

this worked for me. 1. click on window-> preferences -> installed jre. 2. check if you reference is for jdk as shown in the image below. enter image description here

if not, click on add-> standard vm -> give the jdk path by selecting the directory and click on finish as shown in the image enter image description here

  1. last step, click on installed jres -> execution environments -> select your jde as shown in the image below enter image description here

  2. maven -> clean

score:10

add this configurations in pom.xml

<project ...>
    ...
    <build>
        ...
        <plugins>
            <plugin>
                <artifactid>maven-compiler-plugin</artifactid>
                <version>3.1</version>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                    <fork>true</fork>
                    <executable>c:\program files\java\jdk1.7.0_79\bin\javac</executable>
                </configuration>
            </plugin>
        </plugins>
    </build>
    ...
</project>

score:14

i tried all the things; the one that worked for me is:

  1. right click on eclipse project and navigate to properties.
  2. click on java build path and go to the libraries tab.
  3. check which version of java is added there; is it jre or jdk?
  4. if you are using maven project and want to build a solution.
  5. select the jre added their and click remove.
  6. click add external class folder and add the jdk install by selecting from the system.
  7. click apply and ok.
  8. restart eclipse.
  9. build succeeded.

score:16

go into window > preferences > java > installed jres > and check your installed jres. you should have an entry with a jdk there.

https://cduu.wordpress.com/2013/03/08/maven-eclipse-compiler-error-no-compiler-is-provided-in-this-environment/

score:29

screen_shot add 'tools.jar' to installed jre.

  1. eclipse -> window -> preference.
  2. select installed jres -> edit
  3. add external jars
  4. select tools.jar from java/jdkx.x/lib folder.
  5. click finish

Related Query

More Query from same tag