我正在尝试运行WordCount示例。但是我在编译程序时遇到了一些问题。
我得到错误:
执行后错误:package org.apache.hadoop.mapred不存在
:
javac -classpath /usr/local/hadoop/share/hadoop/common/hadoop-common-2.7.3.jar -d wordcount_classes WordCount.java
我使用本教程设置hadoop。我还在stackoverflow:问题上查找了这个问题,并在/usr/local/hadoop
中执行了bin/hadoop classpath
命令。这是我得到的输出:
/usr/local/hadoop/etc/hadoop:/usr/local/hadoop/share/hadoop/common/lib/*:/usr/local/hadoop/share/hadoop/hdfs:/usr/local/hadoop/share/hadoop/hdfs/lib/*:/usr/local/hadoop/share/hadoop/hdfs/hdfs/*:/usr/local/hadoop/share/hadoop/yarn/lib/*:/usr/local/hadoop/share/hadoop/yarn/lib/*:/usr/local/hadoop/share/hadoop/mapreduce/lib/*:/usr/local/hadoop/share/hadoop/mapreduce/lib/*:/usr/local/hadoop/share/hadoop/mapreduce/lib/*:/usr/local/hadoop/share/hadoop/mapreduce/contrib/capacity-scheduler/*.jar
但我不知道该怎么做,也不知道下一步该怎么办!请帮助!
您正在尝试使用许多hadoop依赖jar (hadoop-common-x.x.x.jar)之一编译源代码。包含错误消息中指出的映射包的jar是hadoop-mapreduce-client-core jar。
我建议你使用像Maven或Gradle这样的构建工具来构建你的源代码,因为它会为你管理可传递的依赖关系。
或者继续手动调用javac,请尝试这样做(未经测试):
javac -cp '/usr/local/hadoop/share/hadoop/common/*'
-cp '/usr/local/hadoop/share/hadoop/hdfs/lib/*'
-cp '/usr/local/hadoop/share/hadoop/hdfs/*'
-cp '/usr/local/hadoop/share/hadoop/yarn/lib/*'
-cp '/usr/local/hadoop/share/hadoop/yarn/*'
-cp '/usr/local/hadoop/share/hadoop/mapreduce/lib/*'
-cp '/usr/local/hadoop/share/hadoop/mapreduce/*'
-d wordcount_classes WordCount.java