Maven install Hadoop from source, looking in the wrong path for tools.jar
hadoop, java, maven
Solution
Ran the following to solve the issue on my mac:
cd /Library/Java/JavaVirtualMachines/jdk1.7.0_55.jdk/Contents/Home/
sudo mkdir Classes
cd Classes/
sudo ln -s ../jre/lib/rt.jar classes.jar
Ref: http://ilovemylinux.blogspot.com/2013/05/maven-jspc-compile-error-with-java-7-on.html
Problem
I am trying to build hadoop-2.4.0-src, using 'mvn clean install'. About half of it completes successfully, but then the HDFS projetc fails with: `Exception in thread "main" java.lang.AssertionError: Missing tools.jar at: /Library/Java/JavaVirtualMachines/jdk1.7.0_55.jdk/Contents/Home/Classes/classes.jar. Expression: file.exists()` `....../Home/Classes/` does not exist, and tools.jar is in `......../Home/lib`. My `$JAVA_HOME` environment variable is definitely set correctly, and the JDK listed in the error message is correct - it's just looking in the wrong place within that path. I have seen some postings that a common problem is that people are using the JRE and not the JDK, but I am certain that mine is the JDK. I have tried both suggestions from the accepted answer here: Buiding Hadoop with Eclipse / Maven - Missing artifact jdk.tools:jdk.tools:jar:1.6 ...with no success. Adding the 'dependency' block to Hadoop's pom.xml had no effect, and for the second suggestion I changed the relevant version numbers from 1.6 to 1.7. I have also tried various other suggestions from similar questions without success. `which` returns what I expect: ``` $ which javac /Library/Java/JavaVirtualMachines/jdk1.7.0_55.jdk/Contents/Home/bin/javac ``` However, the contents of JavaVM.framework/Versions seems strange to me, as it does not appear to list 1.7: ``` /System/Library/Frameworks/JavaVM.framework/Versions $ ls -al total 64 drwxr-xr-x 11 root wheel 374 May 10 11:05 ./ drwxr-xr-x 12 root wheel 408 May 10 11:05 ../ lrwxr-xr-x 1 root wheel 10 May 10 11:05 1.4@ -> CurrentJDK lrwxr-xr-x 1 root wheel 10 May 10 11:05 1.4.2@ -> CurrentJDK lrwxr-xr-x 1 root wheel 10 May 10 11:05 1.5@ -> CurrentJDK lrwxr-xr-x 1 root wheel 10 May 10 11:05 1.5.0@ -> CurrentJDK lrwxr-xr-x 1 root wheel 10 May 10 11:05 1.6@ -> CurrentJDK lrwxr-xr-x 1 root wheel 10 May 10 11:05 1.6.0@ -> CurrentJDK drwxr-xr-x 8 root wheel 272 May 10 11:05 A/ lrwxr-xr-x 1 root wheel 1 May 10 11:05 Current@ -> A lrwxr-xr-x 1 root wheel 59 May 10 11:05 CurrentJDK@ -> /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents ``` I am relatively new to Java, so I'm having trouble figuring out where the root of the problem is - is it my local directory tree, as shown by the odd contents of `Versions`? Is Java not configured correctly (although I have been using Java 1.7 in Eclipse for weeks now with no issues)? Or is it an issue with Hadoop's pom.xml I need to update somehow? Thanks for any help.