In the pom.xml for a java project, I get missing artifact jdk.tools:jdk.tools:jar:1.6 error

后端 未结 7 881
执念已碎
执念已碎 2021-02-05 05:20

I think I know how to solve the problem except: I don\'t know where in the pom the specific version is referred to (I do not see it explicitly) and the solution I have seen is t

相关标签:
7条回答
  • 2021-02-05 05:59

    you merely need to add the dependency to tools.jar in your pom.xml file.

    <dependency>
    <groupId>jdk.tools</groupId>
    <artifactId>jdk.tools</artifactId>
    <version>1.7.0_05</version>
    <scope>system</scope>
    <systemPath>${JAVA_HOME}/lib/tools.jar</systemPath>
    </dependency>
    

    If the error persists, change the path to tools.jar to an absolute path as shown below:

    <systemPath>C:/Program Files/Java/jdk1.8.0_65/lib/tools.jar</systemPath>
    
    0 讨论(0)
  • 2021-02-05 06:02
    <dependency>
        <groupId>jdk.tools</groupId>
        <artifactId>jdk.tools</artifactId>
        <version>1.7</version>
        <scope>system</scope>
        <systemPath>C:/jdk1.7.0_51/lib/tools.jar</systemPath>
    </dependency>
    
    0 讨论(0)
  • 2021-02-05 06:12

    You can use the "java.home" environment variable :

    <dependency>
       <groupId>com.sun</groupId>
       <artifactId>tools</artifactId>
       <version>1.6</version>
       <scope>system</scope>
       <systemPath>${java.home}/lib/tools.jar</systemPath>
    </dependency>
    

    Please have a look to : https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#System_Dependencies

    0 讨论(0)
  • 2021-02-05 06:13

    I figured out the solution to this problem in eclipse.

    In Eclipse,

    Navigate to Window -> Preferences

    On the left hand pane, expand Java and you will find the "Installed JREs" entry

    Select that and you should be able to see the JRE entry that is referring to the JRE folder rather than the JDK folder.

    Select the entry to edit it and then redirect it to the JDK folder and click on Apply.

    This solved my problem right away.

    0 讨论(0)
  • 2021-02-05 06:21

    For anyone who stumbles over this issue in the future, read on for a more elegant solution:

    Reason

    This issue crops up in one of the two scenarios:

    1. You do not have JDK installed and configured; or

    2. You've both JDK and JRE installed and JRE is getting precedence over the JDK path.

    Solution

    As explained in this link by the team at 'Hadoop in the real world', you merely need to add the dependency to tools.jar in your pom.xml file.

    <dependency>
    <groupId>jdk.tools</groupId>
    <artifactId>jdk.tools</artifactId>
    <version>1.7.0_05</version>
    <scope>system</scope>
    <systemPath>${JAVA_HOME}/lib/tools.jar</systemPath>
    </dependency>
    

    If the error persists, then just change the path to tools.jar to an absolute path as shown below:

    <systemPath>C:/Program Files/Java/jdk1.8.0_65/lib/tools.jar</systemPath>
    
    0 讨论(0)
  • 2021-02-05 06:23

    As I figured the best way to tackle this is to add the following configuration to your eclipse.ini to make sure it uses the jdk copy of javaw while running eclipse instead of the JRE copy which solves the problem and seems to be the correct approach to fix the issue

    -vm
    C:/Program Files/Java/jdk1.8.0_73/bin/javaw.exe
    
    0 讨论(0)
提交回复
热议问题