Eclipse/Maven error: “No compiler is provided in this environment”

前端 未结 24 1315
庸人自扰
庸人自扰 2020-11-27 04:36

I am a relative newcomer to the world of Java enterprise development. My organization\'s Java guru is out on indefinite family leave, and I have been assigned the task of m

相关标签:
24条回答
  • 2020-11-27 05:14

    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>
    
    0 讨论(0)
  • 2020-11-27 05:14

    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.

    0 讨论(0)
  • 2020-11-27 05:17

    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.
    0 讨论(0)
  • 2020-11-27 05:18

    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.

    0 讨论(0)
  • 2020-11-27 05:21

    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

    0 讨论(0)
  • 2020-11-27 05:24

    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>
    
    0 讨论(0)
提交回复
热议问题