Build error: missing artifact com.sun:tools:jar:1.

2019-02-12 04:36发布

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>

标签: java maven playn
13条回答
爷的心禁止访问
2楼-- · 2019-02-12 05:19

This artifact is always handled as a 'system' dependency. It is never stored in a repo.

See 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.

查看更多
Juvenile、少年°
3楼-- · 2019-02-12 05:19

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):

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:

<dependency>
    <groupId>com.sun</groupId>
    <artifactId>tools</artifactId>
    <version>1.4.2</version>
</dependency>
查看更多
做个烂人
4楼-- · 2019-02-12 05:21

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:

-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. 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.

查看更多
迷人小祖宗
5楼-- · 2019-02-12 05:21

I'm testing on Ubuntu. I'm not very familiar with Java tools. Installing JDK solved the issue for me.

aptitude install openjdk-6-jdk
查看更多
三岁会撩人
6楼-- · 2019-02-12 05:22

This Apple Developer article states:

tools.jar does not exist. Classes usually located here are instead included in classes.jar. Scripts that rely on the existence of tools.jar need to be rewritten accordingly.

查看更多
冷血范
7楼-- · 2019-02-12 05:27

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):

-vm
C:\Program Files\Java\jdk1.7.0_79\bin
查看更多
登录 后发表回答