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.

About these ads

March 11, 2009 - Posted by | Maven

9 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

  4. RIGHT cLICK ON pROJECT -> PROPRTIES -> jAVA BUILD PATH -> SELECT jre sYSTEM PATH -> edit -> SELECT WORKSPACE DEFAULT jre ( POINT IT TO JDK > 1.4 )

    Comment by ashis | September 8, 2010 | Reply

  5. [...] Missing com.sun:tools:jar:1.4.2 March 2009 4 comments 4 [...]

    Pingback by 2010 in blog review « Hobione's Weblog | January 7, 2011 | Reply

  6. Set your eclipse to run with a JDK instead of JRE.

    In Windows, modify eclipse.ini, adding:
    -vm
    C:/java/jdk1.6.0_25/bin/javaw.exe

    http://wiki.eclipse.org/FAQ_How_do_I_run_Eclipse%3F#Find_the_JVM

    Comment by Cristian | February 2, 2012 | Reply

  7. This can also happen when your JRE path cotain spaces for example C:/Program Files/java/jdk1.6.0_25/bin/javaw.exe – java dont like spaces. Change the path (reinstall) to C:/java/jdk1.6.0_25/bin/javaw.exe and set the same in Properties>Java>JRE and eclipse.ini setup file.

    Comment by some_developer | April 25, 2012 | Reply

  8. obviously like your website however you have to check the spelling on quite a few of
    your posts. A number of them are rife with spelling issues and
    I in finding it very bothersome to tell the reality however I’ll definitely come back again.

    Comment by Kelley | May 28, 2013 | Reply

  9. Add this dependecy in pom.xml file.hope this help.

    in property you have to write your jdk lib path..

    com.sun
    tools
    1.4.2
    system
    C:/Program Files/Java/jdk1.6.0_30/lib/tools.jar

    Regards
    ——-
    Divyang Patel
    Jr. Devloper
    Scalsys Technology(India)

    Comment by DivyangPatel | July 12, 2013 | Reply


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: