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

后端 未结 30 1989
长情又很酷
长情又很酷 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:02

    It sounds like Maven is using the JRE, not the JDK. Perhaps you installed Maven before installing the JDK?

    Check the settings files. There are three in total, system, user, and project. It's most likely in the installation configuration ($M2_HOME/conf/settings.xml) or, possibly, the per-user configuration (${user.dir}/.m2/settings.xml).

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

    Setting fork to true resolved the issue for me.

    <configuration>
        <fork>true</fork>
        <source>1.6</source>
        <target>1.6</target>
    </configuration>
    
    0 讨论(0)
  • 2020-11-30 21:05

    I had exact the same problem! I had been searching and searching for days because all the babble about "put the -vm c:\program files\java\jdkxxxxx\bin" in the ini ar as argument for a shortcut did not at all help!

    (Do I sound frustrated? Believe me, that's an understatement! I am simply furious because I lost a week trying to make Maven reliable!)

    I had very unpredictable behavior. Sometimes it compiled and sometimes not. If I did a maven clean, it could not find the compiler and failed. If I then changed something in the build path, it suddenly worked again!!

    Until I went to menu WindowPreferencesJavaInstalled JRE's. I added a new JRE using the location of the JDK and then removed the JRE. Suddenly Maven ran stable!

    Maybe this is worth putting in letters with font-size 30 or so in the Apache manual?

    With all due respect, this is simply outrageous for the Java community! I can't imagine how many days were lost by all these people, trying to work out their problems of this kind! I cannot possibly imagine this is released as a final version. I personally would not even dare to release such a thing under the name beta software...

    Kind regards either way.... After a week of tampering I can finally start developing. I hope my boss won't find out about this. It took me lots of effort to convince him not to go to .NET and I already feel sorry about it.

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

    Don't forget that if you are running your project from a particular Eclipse configuration, you should change the Java Runtime within 'Run Configurations' --> 'Your maven configuration' --> 'JRE tab'after you add the right JDK to your Eclipse preferences.

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

    Eclipse setup only

    Do the following steps:

    1. Right click on Eclipse project Properties

    2. Java Build Path → Libraries

    3. Select JRE System Library → Click the Edit button

    4. Click "Installed JREs..." button

    5. Edit JRE as: Set JRE Home = JAVA_HOME or JAVA_HOME\jre

    Screenshot:

    Enter image description here

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

    Do Echo %JAVA_HOME% and then mvn --version.

    The JRE path should be same... then go menu WindowPreferencesJavaInstalled JRE's location should be same as what Java_Home is showing.

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