简体   繁体   English

构建错误:缺少工件 com.sun:tools:jar:1.6

[英]Build error: missing artifact com.sun:tools:jar:1.6

Trying to build PlayN sample projects I get:尝试构建 PlayN 示例项目,我得到:

Missing artifact com.sun:tools:jar:1.6  pom.xml /playn-cute line 6  Maven Dependency Problem

On every pom.xml file.在每个pom.xml文件上。 How do I resolve it?我该如何解决?

Edit :编辑

I've added the profiles node to the pom.xml , but the error remains.我已将配置文件节点添加到pom.xml ,但错误仍然存​​在。 I've checked the tools.jar is actually exists, and it didn't.我已经检查过tools.jar确实存在,但它没有。 So I've added tools.jar to lib folder.所以我已经将tools.jar添加到 lib 文件夹中。 And still the error remains.并且错误仍然存​​在。

The full pom.xml:完整的 pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>com.googlecode.playn</groupId>
        <artifactId>playn-project</artifactId>
        <version>1.0.1</version>
    </parent>

    <artifactId>playn-cute</artifactId>
    <name>PlayN Cute Metaproject</name>
    <version>1.0-SNAPSHOT</version>
    <packaging>pom</packaging>

    <properties>
        <playn.version>1.0.1</playn.version>
    </properties>

    <modules>
        <module>core</module>
        <module>java</module>
        <module>html</module>
        <!-- <module>flash</module> -->
        <module>android</module>
    </modules>

    <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>
</project>

This artifact is always handled as a 'system' dependency.此工件始终作为“系统”依赖项处理。 It is never stored in a repo.它永远不会存储在回购中。

See https://web.archive.org/web/20151031071007/http://maven.apache.org/general.html#tools-jar-dependency for the details.有关详细信息,请参阅https://web.archive.org/web/20151031071007/http://maven.apache.org/general.html#tools-jar-dependency

if there is no tools jar, and you aren't on a Mac, you are trying to use a JRE when the requirement is a JDK.如果没有工具 jar,并且您不在 Mac 上,那么当要求是 JDK 时,您正在尝试使用 JRE。 You can't turn one into the other by copying file.你不能通过复制文件把一个变成另一个。

I had the same issue when using Eclipse in Windows 7, even when I removed the JRE from the list of JREs in the Eclipse settings and just had the JDK there.在 Windows 7 中使用 Eclipse 时我遇到了同样的问题,即使我从 Eclipse 设置中的 JRE 列表中删除了 JRE 并且只有 JDK。 Your question doesn't state if you're using command-line Maven, or Eclipse, so I thought I'd share what fixed it for me in Eclipse.您的问题没有说明您使用的是命令行 Maven 还是 Eclipse,所以我想我会分享在 Eclipse 中为我修复的问题。

What I ended up having to do was modify the command-line for the shortcut I use to launch Eclipse to add the -vm argument to it like so:我最终要做的是修改我用来启动 Eclipse 的快捷方式的命令行,以向其中添加 -vm 参数,如下所示:

-vm "T:\Program Files\Java\jdk1.6.0_26\bin"

Of course, you would adjust that to point to the bin directory of your JDK install.当然,则需要调整,使其指向你的JDK的bin目录中安装。 What this does is cause Eclipse itself to be running using the JDK instead of JRE, and then it's able to find the tools.jar properly.这会导致 Eclipse 本身使用 JDK 而不是 JRE 运行,然后它能够​​正确地找到tools.jar

There are many reasons you might see this error on your eclipse IDE在 Eclipse IDE 上看到此错误的原因有很多

  1. Eclipse pointing to JRE rather than JDK Eclipse 指向 JRE 而不是 JDK
  2. JDK library not containing tools.jar JDK 库不包含 tools.jar

For this you might want to add tools.jar by yourself through Preferences -> Java -> Installed JRE -> (select JDK, edit and add external jars -> navigate to tools.jar)为此,您可能希望通过 Preferences -> Java -> Installed JRE ->(选择 JDK,编辑并添加外部 jars -> 导航到 tools.jar)自行添加 tools.jar

  1. Other reason might be this -> the parent maven repository of your project have a jar with the same name under some other artifactory.其他原因可能是这个 -> 您项目的父 maven 存储库在其他一些工件下有一个同名的 jar。

You need to locate tools.jar through -> Dependency Heirarchy view for pom.xml in eclipse and once you have located the jar you can add an exclusion there您需要通过 -> eclipse 中 pom.xml 的 Dependency Heirarchy 视图找到 tools.jar,一旦找到 jar,您就可以在那里添加排除项

like ->喜欢->

<groupId>com.parent.project</groupId>
    <artifactId>parent-project-dependencies-pom</artifactId>
    <version>${dependencies.version}</version>
        <exclusions>
            <exclusion>
                <groupId>com.sun</groupId>
                <artifactId>tools</artifactId>
            </exclusion>
         </exclusions>

I'm testing on Ubuntu.我正在 Ubuntu 上测试。 I'm not very familiar with Java tools.我对 Java 工具不是很熟悉。 Installing JDK solved the issue for me.安装JDK为我解决了这个问题。

aptitude install openjdk-6-jdk

I also had this problem, and although the java_path was ok, the problem persisted.我也有这个问题,虽然java_path没问题,但问题依旧。 The fix which worked for me was:对我有用的修复是:

Run this command ( where Dfile points to your tools.jar ):运行此命令(其中 Dfile 指向您的 tools.jar ):

mvn install:install-file -DgroupId=com.sun -DartifactId=tools -Dversion=1.4.2 -Dpackaging=jar -Dfile="C:\Program Files\Java\jdk1.6.0_26\lib\tools.jar"

Then in the main pom.xml add the reference to the dependency:然后在主 pom.xml 中添加对依赖项的引用:

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

You shouldn't need to add the dependency to your POM.您不需要向 POM 添加依赖项。 I had this problem in eclipse and it was because eclipse was running in a JRE, not a JDK.我在 eclipse 中遇到了这个问题,这是因为 eclipse 在 JRE 中运行,而不是在 JDK 中运行。

See this question here for the same issue: Missing artifact com.sun:tools:jar对于同一问题,请在此处查看此问题: Missing artifact com.sun:tools:jar

Resolved by specifing the vm eclipse uses.通过指定 vm eclipse 使用来解决。 Also check the build path for your eclipse project is using a JDK, not a JRE.还要检查您的 eclipse 项目的构建路径使用的是 JDK,而不是 JRE。

Having a JDK on the build path, and explictly setting a JDK in the eclipse INI still doesn't work however if the java on the path was a jre not a jdk (windows path, or linux/mac equivilent).在构建路径上有一个 JDK,并在 eclipse INI 中显式设置一个 JDK 仍然不起作用,但是如果路径上的 java 是 jre 而不是 jdk(windows 路径,或 linux/mac 等效)。

Run this from the command line to see what java on your path is: How do I find where JDK is installed on my windows machine?从命令行运行它以查看路径上的 java 是什么: 如何找到 JDK 在我的 Windows 机器上的安装位置?

If its a JRE you should change it to a JDK and relaunch your IDE.如果它是 JRE,您应该将其更改为 JDK 并重新启动您的 IDE。

Some pointers that can help you:一些可以帮助您的提示:

  1. Check if the tools.jar is present in the repo url in pom.xml.检查tools.jar 是否存在于pom.xml 的repo url 中。
  2. Verify the dependency in pom.xml.验证 pom.xml 中的依赖项。 It might be incorrect.它可能是不正确的。 I did not find any jar artifact at http://search.maven.org/#browse%7C96611365 .我在http://search.maven.org/#browse%7C96611365 上没有找到任何 jar 工件。

Thanks.谢谢。

this is how I resolved it.这就是我解决它的方法。 please paste below lines into your eclipse.ini file.请将以下几行粘贴到您的 eclipse.ini 文件中。

-vm path till java.exe (as shown below) -vm 路径直到java.exe(如下图)

-vm C:/Program Files/Java/jdk1.7.0_60/bin/java -vm C:/Program Files/Java/jdk1.7.0_60/bin/java

hope it helps.希望能帮助到你。

This is how I resolved this problem using Jboss Developer Studio 8.1.10 :这就是我使用Jboss Developer Studio 8.1.10解决这个问题的方法:

Add to your jbdevstudio.ini file located in: D:\\Users\\bertrand\\jbdevstudio\\studio these two lines (before -vmargs ):添加到位于以下位置的jbdevstudio.ini文件: D:\\Users\\bertrand\\jbdevstudio\\studio这两行(在-vmargs之前):

-vm
C:\Program Files\Java\jdk1.7.0_79\bin

I had the same problem, it was because of multiple tools.jar files in the path.我遇到了同样的问题,这是因为路径中有多个 tools.jar 文件。

But the problem was specific to work-space pom dependency.但问题是特定于工作空间 pom 依赖性的。 I came to know this, as my other work-spaces in the same eclipse are working fine.我开始知道这一点,因为我在同一个日食中的其他工作空间工作正常。

Steps I have taken to investigate & solve:我采取的调查和解决步骤:

1) Open project pom file 1)打开项目pom文件

2) Go the Dependency Hierarchies section in pom 2)进入pom中的Dependency Hierarchies部分

3) In the upper right corner filter text box, enter the name tools.jar 3)在右上角过滤器文本框中,输入名称tools.jar

4) This will show the dependency hierarchy of the tools.jar file. 4) 这将显示tools.jar 文件的依赖层次结构。

5) In the right hand side Resolved Section , select the tools.jar file and right click on the jar file. 5) 在右侧的Resolved Section ,选择 tools.jar 文件并右键单击该 jar 文件。

6) select the exclusion of the file. 6) 选择排除文件。

Then rebuild the project.然后重建项目。

For me the issue was that I installed JRE but not JDK.对我来说,问题是我安装了 JRE 而不是 JDK。 I know it's weird as JRE should work but it does not.我知道这很奇怪,因为 JRE 应该可以工作,但事实并非如此。 With JDK same version it works good.使用相同版本的 JDK 效果很好。 It's a linux box and no IDE.这是一个 linux 盒子,没有 IDE。

I solved this by manually adding the tools.jar on my jdk installation's /lib to the Eclipse JRE我通过手动将 jdk 安装的 /lib 上的 tools.jar 添加到 Eclipse JRE 解决了这个问题

Window > Preferences > Installed JREs > Edit > Add external jars > select the tools.jar to add Window > Preferences > Installed JREs > Edit > Add external jars > 选择tools.jar来添加

Check in your pom.xml if tools.jar is from any other dependency.如果 tools.jar 来自任何其他依赖项,请检查您的 pom.xml。 Either exclude it from there or remove dependency if not used.如果不使用,要么从那里排除它,要么删除依赖项。

Then check in your problem section if tools.jar error not appearing in eclipse.如果 eclipse 中没有出现 tools.jar 错误,请检查您的问题部分。

在此处输入图片说明

This Apple Developer article states:这篇Apple Developer 文章指出:

tools.jar does not exist. tools.jar 不存在。 Classes usually located here are instead included in classes.jar.通常位于此处的类包含在 classes.jar 中。 Scripts that rely on the existence of tools.jar need to be rewritten accordingly.依赖于 tools.jar 存在的脚本需要相应地重写。

Add this dependecy in pom.xml file.在 pom.xml 文件中添加此依赖项。

In <systemPath> property you have to write your jdk lib path.<systemPath>属性中,您必须编写 jdk lib 路径。

<dependency>  
    <groupId>com.sun</groupId> 
    <artifactId>tools</artifactId>
    <version>1.4.2</version>
    <scope>system</scope>
    <systemPath>C:/Program Files/Java/jdk1.6.0_30/lib/tools.jar</systemPath>
</dependency> 

I had to change what you had:我不得不改变你所拥有的:

<systemPath>${java.home}/../lib/tools.jar</systemPath>

to the explicit path, using the JDK not the JRE like bmargulies said:到显式路径,使用JDK而不是像bmargulies所说的JRE:

 <systemPath>C:/Program Files/Java/jdk1.6.0_24/lib/tools.jar</systemPath>

Hope that helps.希望有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 缺少工件 com.sun:tools:jar - Missing artifact com.sun:tools:jar 找不到工件 com.sun:tools:jar:0 - Could not find artifact com.sun:tools:jar:0 找不到工件 com.sun:tools:jar:14.0.1 - Could not find artifact com.sun:tools:jar:14.0.1 在指定路径找不到工件 com.sun:tools:jar:1.8.0 - Could not find artifact com.sun:tools:jar:1.8.0 at specified path com.sun:tools:jar:在roo中运行“perform eclipse”时缺少1.4.2 - com.sun:tools:jar:1.4.2 missing when running “perform eclipse” in roo Struts2是否需要com.sun:tools:jar:1.5.0? - Struts2 exclude com.sun:tools:jar:1.5.0 required? cxf-codegen-plugin could not find artifact com.sun:tools:jar:1.8.0 from C:\Program Files\Java\jre1.8.0_251/../lib/tools.jar - cxf-codegen-plugin could not find artifact com.sun:tools:jar:1.8.0 from C:\Program Files\Java\jre1.8.0_251/../lib/tools.jar com.sun:tools:jar 的 dependency.systemPath&#39; 必须指定绝对路径,但为 ${tools.jar} - dependency.systemPath' for com.sun:tools:jar must specify an absolute path but is ${tools.jar} 在 java 项目的 pom.xml 中,我缺少工件 jdk.tools:jdk.tools:jar:1.6 错误 - In the pom.xml for a java project, I get missing artifact jdk.tools:jdk.tools:jar:1.6 error 缺少工件com.sun.jdmk:jmxtools:jar:1.2.1 - Missing artifact com.sun.jdmk:jmxtools:jar:1.2.1
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM