8

First, I KNOW THIS HAS BEEN ASKED BEFORE, but none of the solutions work for me and I would like to know why.

I am trying to compile the standard 'WordCount.java' .jar for hadoop on my linux single-node cluster, but keep getting the package org.apache.hadoop.* does not exist error.

I know that I have to edit the $CLASSPATH, but everything I have found online is saying to reference hadoop-core and I cannot find a hadoop-core anywhere in my build (2.4.0). How do I find where org.apache.hadoop.* would exist on my system?

I feel this would be a good 'general' answer since I have seen many questions on this and everyone gives a specific /path/to/classpath/, but it is (apparently) different depending on version and build of hadoop.

drjrm3
  • 4,474
  • 10
  • 53
  • 91

1 Answers1

20

As you said, the CLASSPATH you need depends on version, location, and type of installation. How to install it is a separate discussion, but assuming you have a proper hadoop setup installed, it's easy (though I admit, I have no clue where it is documented).

Hadoop provides a convenient utility to get the CLASSPATH information you need. Run this

bin/hadoop classpath

This should give you the information you need set your classpath for compiling your code.

D'Nabre
  • 2,226
  • 16
  • 13
  • 2
    Thanks! Hopefully this will help anyone else who is having trouble. Everything I was reading was giving specific directions on where the files were located, but this solution will help people no matter how they have it installed! – drjrm3 Nov 03 '14 at 22:06
  • @VineetKaushik supposing you have hadoop correctly configured in your system, open a Terminal window and type `hadoop classpath` and it should output the correct directories where hadoop has its libraries. – Leniel Maccaferri Oct 14 '16 at 15:45