Hadoop编译WordCount程序:class file for org.apache.commons

Hadoop问题:编译WordCount程序报错:class file for org.apache.commons.cli.Optio

第一次编译Hadoop的程序,将安装程序自带的WordCount程序拿出来编译执行,编译时遇到如下错误:

Ubuntu@ubuntu:~/dev/wordcount$ javac -classpath /home/ubuntu/hadoop-1.0.4/hadoop-core-1.0.4.jar -d bin WordCount.java
WordCount.java:53: cannot access org.apache.commons.cli.Options
class file for org.apache.commons.cli.Options not found
    String[] otherArgs = new GenericOptionsParser(conf, args).getRemainingArgs();
                        ^
1 error

在网上搜索了一下,找到了原因,在 classpath 中再加上一个 jar 包即可:

ubuntu@ubuntu:~/dev/wordcount$ javac -classpath /home/ubuntu/hadoop-1.0.4/hadoop-core-1.0.4.jar:/home/ubuntu/hadoop-1.0.4/lib/commons-cli-1.2.jar -d bin WordCount.java
ubuntu@ubuntu:~/dev/wordcount$ ls bin/*.class
bin/WordCount.class  bin/WordCount$IntSumReducer.class  bin/WordCount$TokenizerMapper.class

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/9838f93cef446a8b24573364772977a0.html