我正在尝试使用本书 Data Analytics with Hadoop 中给出的Hadoop MapReduce Word Count示例,该示例让我设置了Hadoop伪分布式开发环境。所以现在我正在尝试运行Word Count示例。我从Hadoop Fundamentals下载了.java文件,WordCount文件夹。本书中给出的开始此过程的代码是:
hostname $ hadoop com.sun.tools.javac.Main WordCount.java
我运行此操作并收到以下错误:
hadoop@gh0st-VirtualBox:/home/gh0st$ hadoop com.sun.tools.javac.Main Downloads/WordCount/WordCount.java
Downloads/WordCount/WordCount.java:32: error: cannot find symbol
job.setMapperClass(WordMapper.class);
^
symbol: class WordMapper
location: class WordCount
Downloads/WordCount/WordCount.java:33: error: cannot find symbol
job.setReducerClass(SumReducer.class);
^
symbol: class SumReducer
location: class WordCount
Note: Downloads/WordCount/WordCount.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
2 errors
WordMapper.java和SumReducer.java文件位于我运行WordCount.java文件的同一个WordCount文件夹中。考虑到我对此的所有阅读,我不知道从哪里开始。我的$JAVA_HOME
是/usr/lib/jvm/java-7-openjdk-amd64/
。我的$CLASS_PATH
是$HADOOP_HOME/share/hadoop/common/hadoop-common-2.7.3.jar
。我不确定需要哪些其他信息才能解决此问题 - 我将添加其他所需的信息。以下链接是我查看和尝试的内容:
我在VirtualBox中使用Ubuntu 14.04。
答案 0 :(得分:4)
经过一番深挖,我找到了答案。答案在以下链接的评论中:Driver Class Compilation Error
我必须将所有文件一起编译。新代码如下所示:
hadoop com.sun.tools.javac.Main Downloads/WordCount/WordCount.java Downloads/WordCount/WordMapper.java Downloads/WordCount/SumReducer.java
希望这有助于某人!
答案 1 :(得分:0)
这对我有用:
Hadoop classpath
:export CLASSPATH=`hadoop classpath`
echo $CLASSPATH
javac -d . WC_Runner.java WC_Mapper.java WC_Reducer.java