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