Java – The package org.apache.hadoop.fs does not exist

The package org.apache.hadoop.fs does not exist… here is a solution to the problem.

The package org.apache.hadoop.fs does not exist

First of all, I know someone has asked this question before but none of the solutions work for me and I wonder why.

I’m 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 I have to edit $CLASSPATH, but everything I find online says reference hadoop-core and I can’t find hadoop-core anywhere in my build (2.4.0). How do I find the location of org.apache.hadoop.* on my system?

I feel like this would be a good “general” answer, as I’ve seen a lot of questions about this and everyone gives specific /path/to/classpath/, but it (obviously) varies depending on the version and build of Hadoop.

Solution

AS YOU SAID, THE CLASSPATH YOU NEED DEPENDS ON THE VERSION, LOCATION, AND INSTALLATION TYPE. How to install it is a separate discussion, but assuming you have the correct hadoop installer installed, it’s easy (although I admit, I don’t know where it’s recorded).

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

bin/hadoop classpath

This should give you the information you need to set the classpath to compile your code.

Related Problems and Solutions