缺少工件com.sun:工具:jar [英] Missing artifact com.sun:tools:jar

查看:101
本文介绍了缺少工件com.sun:工具:jar的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在关注入门教程,但在使用Maven导入playn项目后陷入困境。我正在使用在64位Windows 7上运行的Eclipse Indigo。

I've been following the getting started tutorial, but am stuck after I imported the playn project using Maven. I am using Eclipse Indigo running on 64bit Windows 7.

所有导入的项目都有相同的错误:

All the imported projects have the same error:

Missing Artifact com.sun:tools:jar in all the pom.xml files.

经过几个小时的搜索论坛后,我尝试过:

After a couple hours of searching forums I have tried:

安装最新的Java 1.6.029
更改我的 JAVA_HOME 环境变量以指向 \program files \ Java \ jdk1.6_029
更改我的Eclipse Java首选项以使用JRE jdk1.6_029

Installing the latest Java 1.6.029 Changing my JAVA_HOME environment variable to point to \program files\Java\jdk1.6_029 Changing my Eclipse Java preferences to use the JRE jdk1.6_029.

我真的想尝试playn,但为什么有一些帖子我似乎找不到解决方案的共识答案。有人说Sun从64位jdk中删除了一些东西,其他人说你必须编辑你的xml文件,很多人说你已经改变了你的 JAVA_HOME ,另一个人说你必须改变Eclipse的VM选项。

I would really like to experiment with playn, but why there are a few posts I can't seem to find a consenus answer on the solution. Some people say Sun removed something from the 64bit jdk, others say you must edit your xml files, many people have said you have change your JAVA_HOME, and another said you have to change your VM options for Eclipse.

任何有关清除它的帮助都会受到赞赏,并且可能对很多人有用,因为我这里没有特别奇怪的设置。

Any help on clearing this up would be appreciated, and possibly useful for many, since I do not have a particularly odd setup here.

(编辑)
这是第一个项目中的pom.xml。 Eclipse标记行中的错误:

(edit) Here is the pom.xml in the first project. Eclipse flags error in the line which says:

<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.1-SNAPSHOT</version>
  </parent>

  <artifactId>playn-android</artifactId>
  <name>PlayN Android</name>
  <packaging>jar</packaging>

  <repositories>
  </repositories>

  <dependencies>
    <dependency>
      <groupId>com.googlecode.playn</groupId>
      <artifactId>playn-core</artifactId>
      <version>${project.version}</version>
    </dependency>

    <!-- needed because Android uses the same JSON code as playn-java;
         that should be factored into a library shared by both backends -->
    <dependency>
      <groupId>com.googlecode.playn</groupId>
      <artifactId>playn-java</artifactId>
      <version>${project.version}</version>
    </dependency>

    <dependency>
      <groupId>com.google.android</groupId>
      <artifactId>android</artifactId>
      <version>${android.version}</version>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.8.1</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <build>
    <sourceDirectory>src</sourceDirectory>
  </build>
</project>


推荐答案

我刚发布了这个问题关于同样的问题以及我如何解决它,但我会粘贴(并展开)它也在这里,因为它似乎更相关。

I just posted over on this question about this same issue and how I resolved it, but I'll paste (and expand on) it here as well, since it seems more relevant.

我在Windows 7中使用Eclipse时遇到了同样的问题,即使我从列表中删除了JRE Eclipse设置中的JRE,只是在那里有JDK。

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.

我最终必须做的事情(如你在问题中提到的那样)是修改命令行为我用它来启动Eclipse以向其添加-vm参数的快捷方式如下:

What I ended up having to do (as you mentioned in your question) was modify the command-line for the shortcut I use to launch Eclipse to add the -vm argument to it like so:

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

当然,你会调整到指向您的 JDK安装的bin目录。这样做是因为Eclipse本身使用JDK而不是JRE运行,然后它能够​​正确地找到 tools.jar

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在没有指定时发现默认JRE的方式有关。我猜它倾向于更喜欢JRE而不是JDK(为什么,我不知道)并且找到它找到的第一个兼容的JRE。如果像Vladiat0r的回答所暗示的那样关闭Windows注册表项,它会首先查找 HKLM \Software \ JavaSoft \ Java运行时环境键,而不是 HKLM \软件\ JavaSoft \ Java开发套件密钥。

I believe this has to do with how Eclipse finds its default JRE when none is specified. I'm guessing it tends to prefer JRE over JDK (why, I don't know) and goes for the first compatible JRE it finds. And if it's going off of Windows registry keys like Vladiat0r's answer suggests, it looks for the HKLM\Software\JavaSoft\Java Runtime Environment key first instead of the HKLM\Software\JavaSoft\Java Development Kit key.

这篇关于缺少工件com.sun:工具:jar的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆