在线程“main”中运行示例wordcount“exception”

3df52oht  于 2021-06-04  发布在  Hadoop
关注(0)|答案(2)|浏览(341)

我尝试运行示例wordcount程序,我的hdfs文件保存在/input中,输出目录是/output,下面是我执行的命令:

[hadoop-2.2.0]$ bin/hadoop jar $HADOOP_HOME/share/hadoop/mapreduce/sources/hadoop-mapreduce-examples-2.2.0-sources.jar org.apache.hadoop.examples.WordCount /input /output

但我有以下错误:

Exception in thread "main" java.lang.ClassNotFoundException: org.apache.hadoop.examples.WordCount
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:270)
at org.apache.hadoop.util.RunJar.main(RunJar.java:205
nafvub8i

nafvub8i1#

我想那是因为你用的是源文件。您更希望执行$hadoop\u home/share/hadoop/mapreduce/sources/hadoop-mapreduce-examples-2.2.0.jar。也许会有帮助。

icomxhvb

icomxhvb2#

试试hadoop-mapreduce-examples-2.2.0.jar

bin/hadoop jar $HADOOP_HOME/share/hadoop/mapreduce/hadoop-mapreduce-examples-2.2.0.jar wordcount /input /output

如果确实要使用源jar,可以先运行以下命令:

unset HADOOP_CLASSPATH

相关问题