Missing artifact com.sun:tools:jar:1.5.0 maven

一曲冷凌霜 提交于 2019-12-04 00:10:31

Its nothing to do with maven or pom. You are trying to run maven from eclipse and hence you need to make sure that you configure JDK properly in eclipse. I think the version of JDK mentioned in the eclipse is not that is installed. So change in eclipse and point the JRE System Library to your installed JDK path.

beattidp

If you're developing on Mac OS X, this is a known issue. According to the Mac Developer Library,

tools.jar does not exist. Classes usually located here are instead included in classes.jar.

This works for me on the Mac:

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

Check if you have installed Java JDK 6 instead of JRE 6. Then check if you have configured and checked in Eclipse your Java Runtime correctly (Preferences -> Java -> Installed JREs).

When I use mac to compile the project which will use some classes under the tools.jar, I confront the same error, But at linux, everything is OK. So I add maven dependency explicitly, it works. I think the key point is checking if the systemPath is right. ps: My jdk version is 1.7,

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

Can you try

    <dependency>
      <groupId>com.sun</groupId>
      <artifactId>tools</artifactId>
      <version>1.5.0</version>
    </dependency>

or else try to add a new dependency with the following information

Group ID: com.sun

Artifact ID: tools

Version: 1.5.0

This works for me.

If this issue occurs on mac, remove the dependency. and try. By default tools.jar will be included on run time. You have to add this dependency only for windows and linux machine.

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

Ref : maven reference

I also had a similar issue and fixed int the following way.

Go to lib directory of JDK installed path in command prompt. Execute the below command to install to install tools.jar. $mvn install:install-file -DgroupId=sun.jdk -DartifactId=tools -Dpackaging=jar -Dversion=1.6 -Dfile=tools.jar


http://parameshk.blogspot.in

Do as following:

add tools.jar dependency in your pom.xml manually. you can also refer to: http://maven.apache.org/general.html#tools-jar-dependency

<profiles>  
  <profile>  
    <id>default-tools.jar</id>  
    <activation>  
      <property>  
        <name>java.vendor</name>  
        <value>Sun Microsystems Inc.</value>  
      </property>  
    </activation>  
    <dependencies>  
      <dependency>  
        <groupId>com.sun</groupId>  
        <artifactId>tools</artifactId>  
        <version>1.6</version>  
        <scope>system</scope>  
        <systemPath>${java.home}/../lib/tools.jar</systemPath>  
      </dependency>  
    </dependencies>  
  </profile>  
</profiles> 

The should be your jdk version, it seems it's just 1.6.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!