2

I have a maven project in Eclipse where I am using some hadoop libraries (hadoop-common, hadoop-auth, hadoop-hdfs) and these bring in a dependency on jdk.tools. When I check this project out on a different machine, it works fine, but on mine the pom.xml complains about "missing artifact jdk.tools:jdk:tools:jar:1.6". I can fix this by adding a dependency manually and specifying the file on my local drive (eg "${JAVA_HOME}/../lib/tools.jar") but I would like to understand why it works on one computer and not on another - I am assuming there is something wrong with my setup?

I have tried the following:

Made sure Eclipse is running in a JDK by adding "-vm C:\Program Files\Java\jdk1.6.0_25\bin\javaw.exe" to my eclipse.ini file. The only JRE listed under Eclipse preferences Java -> Installed JREs is the same JDK. Tried switching maven version in Eclipse preferences Maven -> Installations between "Embedded (3.0.4)", "External (3.0.4)" and "External (2.2.1)"

Maybe something I need to add/change in my maven settings.xml file?

Any suggestions would be appreciated!

FYI I am using Eclipse Java EE Juno SR1 and M2E 1.2.0.

Matt
  • 3,303
  • 5
  • 31
  • 53

3 Answers3

2

JAVA_HOME should point to the folder where java is installed in settings.xml file make sure you have JAVA_HOME property and it point to correct folder

${JAVA_HOME}/../lib/tools.jar is not correct. it should be ${JAVA_HOME}/lib/tools.jar, since tools.jar is under /lib folder and /lib folder is immediately under ${JAVA_HOME} folder

kachanov
  • 2,696
  • 2
  • 21
  • 16
  • The pathing scheme of "${JAVA_HOME}/../lib/tools.jar" seems to have been codified by some projects, at least with regards to linux ([example](https://repository.cloudera.com/artifactory/cloudera-repos/org/apache/hadoop/hadoop-annotations/2.0.0-cdh4.5.0/hadoop-annotations-2.0.0-cdh4.5.0.pom)). I guess they assume you have JAVA_HOME pointing to the inner JRE? – Ryan Apr 24 '14 at 03:52
1

I also added the following to my eclipse.ini file:

-vm
${JAVA_HOME}/bin

and that seemed to fix my problem.

Note: I am running Eclipse 4.3 (Kepler).

thpatel
  • 160
  • 1
  • 10
  • Much better fix than modifying pom.xml! Be sure to put the -vm before the -vmargs command and use a 64-bit JVM path if using 64-bit Eclipse (or 32 & 32). You also must specify java.exe -- http://wiki.eclipse.org/Eclipse.ini. Tested in Luna. – Adam Shook Jul 11 '14 at 12:39
0

Seems like there are three Options. The first two ensure that first found java is JDK's java and they result in eclipse properly translating system dependency to jar beneath JDK. The last allows a way to not require each user to run eclipse via a special manner but may have implications if your dev environment isn't 100% in sync with your production environment. If you expect jdk.tools 1.6 to be present but did your testing with 1.7 or 1.8 you might be in for a surprise.

  • via eclipse.ini

--launcher.appendVmargs -vm
c:/code/Java/jdk1.8.0_40/jre/bin/server/jvm.dll -vmargs -Dosgi.requiredJavaVersion=1.6

  • via path

set PATH=PATH-TO-JDK\bin;%PATH% PATH-TO-ECLIPSE\eclipse.exe

  • via pom

add tools.jar as jdk.tools:jdk.tools:<JDK version> to your local or private shared repo (nexus/artefactory etc) add dependency to your project

Peter Kahn
  • 12,364
  • 20
  • 77
  • 135