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

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

    You need to indicate JAVA_HOME in mvn.ini (it's in the Maven folder /bin), and your problem will disappear.

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

    I had the same error, because of the JUnit version. I had three 3.8.1, and I have changed to 4.8.1.

    So the solution is:

    You have to go to the POM, and make sure that you dependency looks like this

    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.8.1</version>
      <scope>test</scope>
    </dependency>
    
    0 讨论(0)
  • 2020-11-30 21:08

    You try:

    Go to Preferences/Java/Installed JREs and add one for the location "C:\Program Files\Java\jdk1.6.0_27\jre or something like that.

    Remove the one for C:\Program Files\Java\jre6

    As you can see, the path C:\Program Files\Java\jre6\..\lib\tools.jar only makes sense if the first part (til the /..) is replaced by C:\Program Files\Java\jdk1.6.0_27\jre.

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

    I got the same problem using Run as -> Maven install in Eclipse. JAVA_HOME and eclipse.ini were OK and pointing to my latest JDK. But m2clipse used JRE. Using mvn install outside of Eclipse worked fine!

    In my case, I solved the problem as follows:

    1. Navigate in Eclipse: menu WindowPreferencesJavaInstalled JREs
    2. There were two inactive entries for a JRE and JDK. The active one was the latest installed JDK. Delete all entries but the one Maven should use.

    I think Maven doesn't take into account which one is active...

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

    In my case, in Eclipse menu RunDebug Configurations.

    In the JRE tab selecting the JDK instead of the JRE solved the problem.

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

    The solution to this problem is very simple...

    If you don't have Ant build file then generate it. In Eclipse you can easily create a Ant file.

    Refer to the link to create Ant build file [http://www.codejava.net/ides/eclipse/how-to-create-ant-build-file-for-existing-java-project-in-eclipse].

    Now follow the given steps:

    1) Add your Ant build file in Ant view that is in view window.

    2) right click on your Ant build file and select Run As and the second option in that "Ant Build".

    3) Now a dialog box will open with various options and tabs.

    4) Select the JRE tab.

    5) You will see three radio buttons and they will be having JRE or JDK selected as an option.

    6) Look carefully if the radio button options are having JRE as selected then change it to JDK.

    7) Click apply.

    That's it...!!!

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