java.lang.ClassNotFoundException: 自己编译WordCount编译通过执行报错

1、使用WordCount源代码,修改其Map,在Map中使用IKAnalyzer的分词功能。源码参照:

http://www.cnblogs.com/jiejue/archive/2012/12/16/2820788.html

2、打包上传到Hadoop集群,每台机器都上传,上传时包含了所有相关的jar,放到一个目录下

3、按如下两种方式执行都报错

[hadoop@master wordcount]$ /opt/modules/hadoop/hadoop-1.0.3/bin/hadoop jar ChineseWordCount.jar  /user/root/hadoop/ /output6
Exception in thread "main" java.lang.ClassNotFoundException: /user/root/hadoop/
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at org.apache.hadoop.util.RunJar.main(RunJar.java:149)
[hadoop@master wordcount]$ /opt/modules/hadoop/hadoop-1.0.3/bin/hadoop jar ChineseWordCount.jar  ChineseWordCount /user/root/hadoop/ /output6
Exception in thread "main" java.lang.ClassNotFoundException: WordCount
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at org.apache.hadoop.util.RunJar.main(RunJar.java:149)

4、解决办法:ChineseWordCount增加命名空间;~~~都是默认示例惹的祸,默认示例[hadoop@master hadoop-1.0.3]$hadoop jar hadoop-examples-1.0.3.jar  wordcount /user/root/hadoop/ /output5 执行成功。

正确执行命令:[hadoop@master wordcount]$ /opt/modules/hadoop/hadoop-1.0.3/bin/hadoop jar ChineseWordCount.jar  org.apache.hadoop.examples.ChineseWordCount /user/root/hadoop/ /output6

你可能感兴趣的:(java.lang.ClassNotFoundException: 自己编译WordCount编译通过执行报错)