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

查看:36
本文介绍了缺少工件 com.sun:tools: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 filesJavajdk1.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 filesJavajdk1.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 时遇到了同样的问题,即使我从 Eclipse 设置中的 JRE 列表中删除了 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 FilesJavajdk1.6.0_26in"

当然,您可以将其调整为指向 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 有关.我猜它往往更喜欢 JRE 而不是 JDK(为什么,我不知道),并且会选择它找到的第一个兼容的 JRE.如果它像 Vladiat0r 的回答所暗示的那样脱离了 Windows 注册表项,它会首先查找 HKLMSoftwareJavaSoftJava Runtime Environment 键而不是 HKLMSoftwareJavaSoftJava Development套件键.

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 HKLMSoftwareJavaSoftJava Runtime Environment key first instead of the HKLMSoftwareJavaSoftJava Development Kit key.

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

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