分隔的所有jar的绝对路径
我是CDH4和Hadoop新手。
我正在尝试运行wordcountexample并得到以下错误。你能纠正我,让我知道是什么问题吗?
WordCount.java:25: interface expected here
public static class Map extends MapReduceBase implements Mapper<LongWritable, Text, Text, IntWritable> {
^
WordCount.java:39: interface expected here
public static class Reduce extends MapReduceBase implements Reducer<Text, IntWritable, Text, IntWritable> {
^
WordCount.java:56: setMapperClass(java.lang.Class<? extends org.apache.hadoop.mapred.Mapper>) in org.apache.hadoop.mapred.JobConf cannot be applied to (java.lang.Class<WordCount.Map>)
conf.setMapperClass(Map.class);
^
WordCount.java:57: setCombinerClass(java.lang.Class<? extends org.apache.hadoop.mapred.Reducer>) in org.apache.hadoop.mapred.JobConf cannot be applied to (java.lang.Class<WordCount.Reduce>)
conf.setCombinerClass(Reduce.class);
^
WordCount.java:58: setReducerClass(java.lang.Class<? extends org.apache.hadoop.mapred.Reducer>) in org.apache.hadoop.mapred.JobConf cannot be applied to (java.lang.Class<WordCount.Reduce>)
conf.setReducerClass(Reduce.class);
^
WordCount.java:60: setInputFormat(java.lang.Class<? extends org.apache.hadoop.mapred.InputFormat>) in org.apache.hadoop.mapred.JobConf cannot be applied to (java.lang.Class<org.apache.hadoop.mapreduce.lib.input.TextInputFormat>)
conf.setInputFormat(TextInputFormat.class);
^
WordCount.java:63: cannot find symbol
symbol : method setInputPaths(org.apache.hadoop.mapred.JobConf,org.apache.hadoop.fs.Path)
location: class org.apache.hadoop.mapreduce.lib.input.FileInputFormat
FileInputFormat.setInputPaths(conf, new Path(args[0]));
^
WordCount.java:64: setOutputPath(org.apache.hadoop.mapreduce.Job,org.apache.hadoop.fs.Path) in org.apache.hadoop.mapreduce.lib.output.FileOutputFormat cannot be applied to (org.apache.hadoop.mapred.JobConf,org.apache.hadoop.fs.Path)
FileOutputFormat.setOutputPath(conf, new Path(args[1]));
编译命令:
javac -classpath /usr/lib/hadoop/*:/usr/lib/hadoop/client/* WordCount.java
程序是wordcountexample
问题是-classpath
选项。您需要给出jar的绝对路径。*
是不够的。给出用:
对于CHD4请尝试:
$ javac -classpath 'hadoop classpath' WordCount.java