Maven build failed: “Unable to locate the Javac Compiler in: jre or jdk issue”

后端 未结 30 1992
长情又很酷
长情又很酷 2020-11-30 20:33

I have my JAVA_HOME set to:

C:\\Program Files (x86)\\Java\\jdk1.6.0_18

After I run maven ins

相关标签:
30条回答
  • 2020-11-30 21:13

    I changed the configuration of maven-compiler-plugin to add executable and fork with value true.

    <configuration>
        <fork>true</fork>
        <source>1.6</source>
        <target>1.6</target>
        <executable>C:\Program Files\Java\jdk1.6.0_18\bin\javac</executable>
    </configuration>
    

    It worked for me.

    0 讨论(0)
  • 2020-11-30 21:15

    Go to Eclipse's menu WindowPreferences...JavaInstalled JREs should point to the JDK you installed, not to the JRE.

    0 讨论(0)
  • 2020-11-30 21:16

    As mentioned by several others, the Eclipse WindowPreferences...JavaInstalled JREs should point to the JDK you installed, not to the JRE. Only then it can find the ../lib folder mentioned in the error message.

    Even with this, the problem may recur. My way out in Eclipse v4.2 (Juno) is to do a menu MavenUpdate project... after which the problem disappears.

    I suspect the reason is that some of the Eclipse generated files (.classpath, .project, .preferences) are in Subversion for the project in which I'm having these problems. Thus, an SVN update introduces the problem, and an configuration update from Maven in Eclipse resolves it again.

    Real solution: omit Eclipse generated .files from version control, and let the Maven Eclipse plugin handle project configuration. (Additional pointers/suggestions are welcome).

    0 讨论(0)
  • 2020-11-30 21:16

    Many other answers tell you to point your Eclipse to a JDK instead of a JRE.

    Here is another answer with more specific/clear [than I have seen in any answer here] step-by-steps on how to do that: How do you install JDK?

    That is what for solved me for this same problem.

    0 讨论(0)
  • 2020-11-30 21:18

    You could try updating the JDK Eclipse is using, as follows:

    Add and set the JRE in menu WindowPreferences...JavaInstalled JREs:

    JRE type: Standard VM JRE
    Name: jdk1.6.0_18
    JRE home directory: C:\Program Files (x86)\Java\jdk1.6.0_18
    

    If this is not the case, it's possible that the brackets and spaces in the JAVA_HOME path are causing issues. Try copying your JDK to a different location and updating your JAVA_HOME.

    0 讨论(0)
  • 2020-11-30 21:18

    Based on Compiling Sources Using A Different JDK, you will have to set the fork to true in your pom.xml file.

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