A mind that is stretched by a new experience can never go back to its old dimensions.

Can’t compile the example WordCount.java (Hadoop)

December 2nd, 2009 Posted in from the road, geek out, popular

http://mail-archives.apache.org/mod_mbox/hadoop-common-user/200907.mbox/%3Cd6d7c4410907201717t672e4caet3f369d7e4327ff7b@mail.gmail.com%3E

Seen this?

Rajat@rtde ~/java
$ javac -classpath /home/Rajat/hadoop-0.20.1/hadoop-0.20.1-core.jar -d
wordcount_classes WordCount.java

WordCount.java:5: package org.apache.hadoop.fs does not exist
import org.apache.hadoop.fs.Path;

WordCount.java:6: package org.apache.hadoop.conf does not exist
import org.apache.hadoop.conf.*;
^
WordCount.java:7: package org.apache.hadoop.io does not exist
import org.apache.hadoop.io.*;
^
WordCount.java:8: package org.apache.hadoop.mapred does not exist
import org.apache.hadoop.mapred.*;
^
WordCount.java:9: package org.apache.hadoop.util does not exist
import org.apache.hadoop.util.*;

And running CygWin on Windows? Tried everything for your classpath
huh? Try this:

$ javac -verbose -classpath C:\\cygwin\\home\\Rajat\\hadoop-0.20.1\\hadoop-0.20.1-core.jar -d wordcount_classes WordCount.java

(Change your cygwin path, obviously)

Use the -verbose flag to show the entire class search path.


  1. 5 Responses to “Can’t compile the example WordCount.java (Hadoop)”

  2. By Kiran @ What is Hadoop? on Jan 20, 2012

    Thanks for solving issues.

    We can solve these errors in many ways in windows.
    1. copy the jar to the jdkhome\lib\ext folder. This is bootstrap classloader which loads all the jars automcatically by java .
    2.other is set the environment variable CLASSPATH=%CLASSPATH%;.;HADOOP JAR LOCATION.
    Please let us know if you think these options works for you.
    Please click here for know more about hadoop
    Introduction to Hadoop
    Kiran @ What is Hadoop? recently posted..Top 10 gzip examples in unix or linux

  3. By srikanth on May 8, 2012

    I am getting the same error in when i run the program in Ubuntu. i have tried setting Classpath in different ways but none has worked. Can you please let me know to handle the same errors in Ubuntu.

  4. By Niels on May 19, 2012

    I got the same error using Cloudera. Turned out I got a newer version of the Hadoop jar.

    The tutorial says

    HADOOP_HOME=/usr/lib/hadoop-0.20
    HADOOP_VERSION=0.20.2-cdh3u1

    But the version in the distribution is:
    HADOOP_VERSION=0.20.2-cdh3u3

    $ javac -classpath ${HADOOP_HOME}/hadoop-${HADOOP_VERSION}-core.jar -d wordcount_classes WordCount.java

    Mabye you have a similar issue?

  5. By pranav on Jul 8, 2012

    Thanks for solving the issue, was looking for it

  6. By n on Jul 11, 2012

    how to add hadoop.utils package to java?

Post a Comment

CommentLuv badge