构建错误:缺少工件 com.sun:tools:jar:1.6
尝试构建 PlayN 示例项目时,我得到:
Missing artifact com.sun:tools:jar:1.6 pom.xml /playn-cute line 6 Maven Dependency Problem
在每个 pom.xml
文件上。 我该如何解决?
编辑:
我已将 profiles 节点 添加到 pom.xml
,但错误仍然存在。我检查过 tools.jar
确实存在,但它不存在。所以我将 tools.jar
添加到 lib 文件夹中。但错误仍然存在。
完整的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>
Trying to build PlayN sample projects I get:
Missing artifact com.sun:tools:jar:1.6 pom.xml /playn-cute line 6 Maven Dependency Problem
On every pom.xml
file.
How do I resolve it?
Edit:
I've added the profiles node to the pom.xml
, but the error remains. I've checked the tools.jar
is actually exists, and it didn't. So I've added tools.jar
to lib folder. And still the error remains.
The full 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>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(16)
该工件始终作为“系统”依赖项进行处理。它永远不会存储在存储库中。
请参阅 https://maven.apache.org/general.html#tools-jar-dependency" rel="nofollow noreferrer">https:// /web.archive.org/web/20151031071007/http://maven.apache.org/general.html#tools-jar-dependency 了解详细信息。
如果没有工具 jar,并且您使用的不是 Mac,则当要求是 JDK 时,您会尝试使用 JRE。您无法通过复制文件将一个文件转换为另一个文件。
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.
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. You can't turn one into the other by copying file.
在 Windows 7 中使用 Eclipse 时,我遇到了同样的问题,即使我从 Eclipse 设置中的 JRE 列表中删除了 JRE,而只保留了 JDK。您的问题没有说明您使用的是命令行 Maven 还是 Eclipse,所以我想我应该分享在 Eclipse 中为我解决的问题。
我最终要做的是修改用于启动 Eclipse 的快捷方式的命令行,以向其添加 -vm 参数,如下所示:
当然,您可以将其调整为指向您的 bin 目录JDK 安装。这样做的目的是使 Eclipse 本身使用 JDK 而不是 JRE 运行,然后它能够正确找到
tools.jar
。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. 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.
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:
Of course, you would adjust that to point to the bin directory of your JDK install. 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 IDE 上看到此错误
为此,您可能需要通过 Preferences -> 自行添加 tools.jar Java->安装的JRE -> (选择 JDK,编辑并添加外部 jar -> 导航到 tools.jar)
您需要通过->找到tools.jar eclipse 中 pom.xml 的依赖关系层次结构视图,一旦找到 jar,您就可以在其中添加排除项,
例如 ->
There are many reasons you might see this error on your eclipse IDE
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)
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
like ->
我正在 Ubuntu 上测试。我对Java工具不是很熟悉。安装 JDK 解决了我的问题。
I'm testing on Ubuntu. I'm not very familiar with Java tools. Installing JDK solved the issue for me.
我也遇到了这个问题,虽然java_path没问题,但是问题依然存在。对我有用的修复是:
运行此命令(其中 Dfile 指向您的tools.jar):
然后在主 pom.xml 中添加对依赖项的引用:
I also had this problem, and although the java_path was ok, the problem persisted. The fix which worked for me was:
Run this command (where Dfile points to your tools.jar):
Then in the main pom.xml add the reference to the dependency:
您不需要将依赖项添加到 POM 中。我在 eclipse 中遇到这个问题,这是因为 eclipse 运行在 JRE 中,而不是 JDK 中。
对于同一问题,请参阅此处的此问题:缺少工件 com.sun:tools:jar
已解决指定 eclipse 使用的 vm。另请检查 Eclipse 项目的构建路径是否使用 JDK,而不是 JRE。
如果路径上的 java 是 jre 而不是 jdk(Windows 路径或 linux/mac 等效路径),则在构建路径上有 JDK 并在 eclipse INI 中显式设置 JDK 仍然不起作用。
从命令行运行此命令以查看路径上的 java 是什么: 如何找到 Windows 计算机上 JDK 的安装位置?
如果它是 JRE,您应该将其更改为 JDK 并重新启动您的 IDE。
You shouldn't need to add the dependency to your POM. I had this problem in eclipse and it was because eclipse was running in a JRE, not a JDK.
See this question here for the same issue: Missing artifact com.sun:tools:jar
Resolved by specifing the vm eclipse uses. Also check the build path for your eclipse project is using a JDK, not a 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).
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?
If its a JRE you should change it to a JDK and relaunch your IDE.
一些可以帮助您的提示:
谢谢。
Some pointers that can help you:
Thanks.
这就是我解决它的方法。
请将以下行粘贴到您的 eclipse.ini 文件中。
-vm
路径直到java.exe(如下图)
-vm
C:/Program Files/Java/jdk1.7.0_60/bin/java
希望有帮助。
this is how I resolved it.
please paste below lines into your eclipse.ini file.
-vm
path till java.exe (as shown below)
-vm
C:/Program Files/Java/jdk1.7.0_60/bin/java
hope it helps.
这就是我使用 Jboss Developer Studio 8.1.10 解决此问题的方法:
添加到位于以下位置的
jbdevstudio.ini
文件:D:\Users\bertrand\jbdevstudio \studio
这两行(在-vmargs
之前):This is how I resolved this problem using Jboss Developer Studio 8.1.10:
Add to your
jbdevstudio.ini
file located in:D:\Users\bertrand\jbdevstudio\studio
these two lines (before-vmargs
):我遇到了同样的问题,这是因为路径中有多个tools.jar 文件。
但问题是工作空间 pom 依赖性所特有的。我开始知道这一点,因为我在同一个日食中的其他工作空间运行良好。
我已采取的调查和措施解决:
1)打开项目pom文件
2)转到pom中的
Dependency Hierarchies
部分3)在右上角的过滤器文本框中,输入名称tools.jar
4)这将显示工具.jar 文件。
5) 在右侧的
Resolved Section
中,选择tools.jar 文件并右键单击该jar 文件。6) 选择排除该文件。
然后重建项目。
I had the same problem, it was because of multiple tools.jar files in the path.
But the problem was specific to work-space pom dependency. 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
2) Go the
Dependency Hierarchies
section in pom3) In the upper right corner filter text box, enter the name tools.jar
4) This will show the dependency hierarchy of the tools.jar file.
5) In the right hand side
Resolved Section
, select the tools.jar file and right click on the jar file.6) select the exclusion of the file.
Then rebuild the project.
对我来说,问题是我安装了 JRE 但没有安装 JDK。我知道这很奇怪,因为 JRE 应该可以工作,但事实并非如此。使用相同版本的 JDK 效果很好。
这是一个 Linux 盒子,没有 IDE。
For me the issue was that I installed JRE but not JDK. I know it's weird as JRE should work but it does not. With JDK same version it works good.
It's a linux box and no IDE.
我通过手动将 jdk 安装的 /lib 上的 tools.jar 添加到 Eclipse JRE
Window > 解决了这个问题首选项>安装的 JRE >编辑>添加外部罐子>选择要添加的tools.jar
I solved this by manually adding the tools.jar on my jdk installation's /lib to the Eclipse JRE
Window > Preferences > Installed JREs > Edit > Add external jars > select the tools.jar to add
如果tools.jar 来自任何其他依赖项,请检查您的pom.xml。要么将其从那里排除,要么删除依赖项(如果不使用)。
然后检查您的问题部分,如果 eclipse 中没有出现tools.jar 错误。
Check in your pom.xml if tools.jar is from any other dependency. 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.
这篇 Apple 开发者文章状态:
This Apple Developer article states:
在 pom.xml 文件中添加此依赖项。
在
属性中,您必须编写 jdk lib 路径。Add this dependecy in pom.xml file.
In
<systemPath>
property you have to write your jdk lib path.我必须改变你所拥有的:
到显式路径,使用 JDK 而不是像 bmargulies 所说的 JRE:
希望有帮助。
I had to change what you had:
to the explicit path, using the JDK not the JRE like bmargulies said:
Hope that helps.