No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?

后端 未结 30 2197
盖世英雄少女心
盖世英雄少女心 2020-11-22 15:40

I\'m compiling a project in Eclipse using m2eclipse. I set the JDK path in Eclipse like this:

Windows-->preferences-->installed jres--> jdk1.7.xx  p         


        
相关标签:
30条回答
  • 2020-11-22 16:05

    Go to windows -> Preferences -> Java -> Installed JREs

    may be jre is already added

    click on Add -> Standard VM -> Next -> Directory

    and browse for the JDK in my case path was C:\Program Files\Java\jdk1.8.0_111

    then Click on finish.

    you will see window like this

    select JDK -> Apply -> Ok

    And You are done.

    0 讨论(0)
  • 2020-11-22 16:05

    There are several options to specify.

    Steps: Right on project in project explorer Go to Run-> Run Configuration -> Click Maven Build -> Click on your build config/or create a new config. You will see the window as the given snapshot below, click on JRE tab there.

    You see you have 3 options 1) Workspace Default JRE 2)Execution Environment 3)Alternate JRE 1) Workspace Default JRE is set from 'Window' menu on the top -> Preferences -> Java -> Installed JREs -Here you can add your jdk 2) Execution Environment jdk can be set in pom.xml as mentioned by @ksnortum

    <build>
    <plugins>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
                <fork>true</fork>
                <executable>C:\Program Files\Java\jdk1.7.0_45\bin\javac.exe</executable>
            </configuration>
        </plugin>
    </plugins>
    

    3) Alternate JRE can be used to select a jdk from your directory

    0 讨论(0)
  • 2020-11-22 16:06

    For me, nothing worked until I made this change to my pom.xml:

    <build>
    ...
        <plugins>
        ...
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <fork>true</fork>
                    <executable>C:\Program Files\Java\jdk1.7.0_45\bin\javac.exe</executable>
                </configuration>
            </plugin>
        </plugins>
    </build>
    

    Other Notes

    I could see that m2e was executing in a JRE, not the JDK. Nothing I did changed this, including adding this to the eclipse.ini:

    -vm
    C:\Program Files\Java\jdk1.7.0_45\bin\javaw.exe
    

    In the end I never got m2e to execute in a JDK, but setting the Java compiler explicitly (as above) did the trick.

    0 讨论(0)
  • 2020-11-22 16:07

    For me, it is exactly what the maven of eclipse complains

    enter image description here

    So, I press Edit button and change path to the JDK Folder, then clean project and everything starts to work

    0 讨论(0)
  • 2020-11-22 16:10

    I got a solution.

    The most common solution for this problem is to change jdk location as my Installed JREs instead of the JRE location but that did not solve my problem this one time.

    So I did the below to solve the problem. Expand the Installed JREs tab and you will find a Execution environments tab.

    Click on your favourite execution environment. In my case it was JAVASE-1.8. There it shows 2 options. JDK and JRE. Select JDK there and the problem is solved.

    0 讨论(0)
  • 2020-11-22 16:10

    In addition to answer above, I could say that just try to run Maven from the terminal (outside of Eclipse). In this way, if it builds from outside but not in Eclipse, you can understand that the problem should be in Eclipse.

    0 讨论(0)
提交回复
热议问题