Hobione's Weblog

Living & Breathing in Web 2.0 Era

Missing com.sun:tools:jar:1.4.2

Error message: Missing:
----------
1) com.sun:tools:jar:1.4.2

  Try downloading the file manually from the project website.

  Then, install it using the command:
      mvn install:install-file -DgroupId=com.sun -DartifactId=tools -Dversion=1.4.2 -Dpackaging=jar -Dfile=/path/to/file

  Alternatively, if you host your own repository you can deploy the file there:
      mvn deploy:deploy-file -DgroupId=com.sun -DartifactId=tools -Dversion=1.4.2 -Dpackaging=jar -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]

  Path to dependency:
  	1) HRTrainingModel:HRTrainingModel:jar:1.0-SNAPSHOT
  	2) commons-attributes:commons-attributes-compiler:jar:2.1
  	3) com.sun:tools:jar:1.4.2

----------
1 required artifact is missing.

for artifact:
  HRTrainingModel:HRTrainingModel:jar:1.0-SNAPSHOT

from the specified remote repositories:
  Eclipse (http://repo1.maven.org/eclipse/),
  Maven2 (http://repo2.maven.org/maven2/),
  central (http://repo1.maven.org/maven2),
  JBOSS (http://repository.jboss.org/maven2/),
  Ibiblio (http://www.ibiblio.org/maven/mule/dependencies/maven2/)

Group-Id: HRTrainingModel
Artifact-Id: HRTrainingModel
Version: 1.0-SNAPSHOT
From file: C:\WorkspaceMyEclipse\HRTrainingPersistence\pom.xml

Solution: You can use command line to resolve this but here how I did it.
1. Right click on the project to import the jar file manually because, I could not find the tools.jar file from any publicly available repositories.  I have set up the JAVA_HOME = C:\Program Files\Java\jdk1.6.0_10

Import Jar File in Maven Manually

Step 2. Setup Artifact form as follows.

Maven setup artifact

Once you click okay, the Maven repository should looks like as follows.
Maven repository, .m2

3. Now, the last step.  Open up the pom.xml file add the dependency.

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

Under Maven Dependencies, you should able to find tools.jar.
tools.jar

Similar issue:

FAILED for project: 

    HRTrainingModel:HRTrainingModel:jar:1.0-SNAPSHOT

Reason:

Unable to locate the Javac Compiler in:
  C:\Program Files\MyEclipse 6.6\jre\..\lib\tools.jar
Please ensure you are using JDK 1.4 or above and
not a JRE (the com.sun.tools.javac.Main class is required).
In most cases you can change the location of your Java
installation by setting the JAVA_HOME environment variable.

Caution: You must have both the Maven JDK and the default Java JDK set to the same version.
See Jason Lee’s two comments under Comments tab below.

March 11, 2009 - Posted by HobiOne | Maven | | 3 Comments

3 Comments »

  1. Hwy, Hobi. Instead of importing tools.jar into your Maven repo, you should probably do this:

    default-tools.jar

    java.vendor
    Sun Microsystems Inc.

    com.sun
    tools
    1.4.2
    system
    ${java.home}/../lib/tools.jar

    Taken from: http://maven.apache.org/general.html#tools-jar-dependency

    Comment by Jason Lee | March 12, 2009 | Reply

  2. Let me try that again. hehe

    <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.4.2</version>
    <scope>system</scope>
    <systemPath>${java.home}/../lib/tools.jar</systemPath>
    </dependency>
    </dependencies>
    </profile>
    </profiles>

    Comment by Jason Lee | March 12, 2009 | Reply

  3. I’ve tried:

    default-tools.jar

    java.vendor
    Sun Microsystems Inc.

    com.sun
    tools
    1.4.2
    system
    ${java.home}/../lib/tools.jar

    but not working. It says:

    [INFO] Scanning for projects…
    [INFO] ————————————————————————
    [INFO] Building
    [INFO]
    [INFO] Id: com.eon:mslms:war:0.0.1-SNAPSHOT
    [INFO] task-segment: [deploy]
    [INFO] ————————————————————————
    [INFO] [resources:resources]
    [INFO] Using default encoding to copy filtered resources.
    [WARNING] While downloading poi:poi:2.5.1-final-20040804
    This artifact has been relocated to poi:poi:2.5.1-final-20040804.

    [ERROR]

    Transitive dependency resolution for scope: compile has failed for your project.

    Error message: Missing:
    ———-
    1) com.sun:tools:jar:1.4.2

    Try downloading the file manually from the project website.

    Then, install it using the command:
    mvn install:install-file -DgroupId=com.sun -DartifactId=tools -Dversion=1.4.2 -Dpackaging=jar -Dfile=/path/to/file

    Alternatively, if you host your own repository you can deploy the file there:
    mvn deploy:deploy-file -DgroupId=com.sun -DartifactId=tools -Dversion=1.4.2 -Dpackaging=jar -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]

    Path to dependency:
    1) com.eon:mslms:war:0.0.1-SNAPSHOT
    2) com.sun:tools:jar:1.4.2

    ———-
    1 required artifact is missing.

    for artifact:
    com.eon:mslms:war:0.0.1-SNAPSHOT

    from the specified remote repositories:
    com.springsource.repository.bundles.release (http://repository.springsource.com/maven/bundles/release),
    central (http://repo1.maven.org/maven2),
    com.springsource.repository.bundles.external (http://repository.springsource.com/maven/bundles/external)

    Group-Id: com.eon
    Artifact-Id: mslms
    Version: 0.0.1-SNAPSHOT
    From file: D:\Workspaces\MyEclipse 7.1\health\pom.xml

    [INFO] ————————————————————————
    [INFO] For more information, run with the -e flag
    [INFO] ————————————————————————
    [INFO] BUILD FAILED
    [INFO] ————————————————————————
    [INFO] Total time: 2 seconds
    [INFO] Finished at: Tue May 26 01:31:11 ULAST 2009
    [INFO] Final Memory: 3M/15M
    [INFO] ————————————————————————

    Comment by MethoD | May 25, 2009 | Reply


Leave a comment