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:

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.


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

Similar issue:

FAILED for project: 



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 | Maven | 9 Comments

MyEclipse Maven Error: Generics are not supported in -source 1.3

Problem: I got this error:

C:\WorkspaceMyEclipse\HRTrainingPersistence\src\main\java\gov\faa\amc\nas\hrtraining\persistence\TrainingClass.java:[45,2] annotations are not supported in -source 1.3</pre>
(use -source 5 or higher to enable annotations)

Solution: Maven’s default java complier is 1.3 (very weird).  I had to add a plugin tag for Java 1.5,  right after <dependencies> tag.

   <!-- For annotations and other Java5 stuff -->

References: Maven Documentation Home

Q: How to setup Maven JDK Home?
Maven JDK Home setup

Reference: How to fix Maven ‘Add JDK’ warning?

March 4, 2009 Posted by | Maven | 4 Comments