问题描述
我有3个.java文件
1)Mapper.java
2)Reducer.java
3)Driver.java
我试图在Driver类中使用命令行编译hadoop mapreduce程序,但它显示下面的错误
Driver.java:39:错误:找不到符号
job.setMapperClass(Mapper。类);
^
symbol:class Mapper
location:class Driver
Driver.java:40:error:找不到符号
job.setReducerClass(Reducer.class);
如何解决上面的错误。下面是Driver类中的run方法
public boolean runnerParsing(String inputPath,String outputPath)throws IOException,ClassNotFoundException,InterruptedException {
Configuration conf = new Configuration();
Job job = new Job(conf,Parsing);
job.setJarByClass(Driver.class);
job.setOutputKeyClass(Text.class);
job.setOutputValueClass(Text.class);
job.setMapperClass(Mapper.class);
job.setReducerClass(Reducer.class);
//job.setNumReduceTasks(0);
job.setInputFormatClass(TextInputFormat.class);
job.setOutputFormatClass(TextOutputFormat.class);
FileInputFormat.addInputPath(job,new Path(inputPath));
FileOutputFormat.setOutputPath(job,new Path(outputPath));
return job.waitForCompletion(true);
$ / code $ / pre
解决方案需要编译所有java文件,如下所示:
javac -classpath /usr/local/hadoop/hadoop-core-1.2.1.jar - d compiled_classes Driver.java Mapper.java Reducer.java
请注意,根据您安装Hadoop的方式,您的classpath值可能会稍有变化。 / p>
如果您需要进一步帮助,请查看本文,这可能会对您有所帮助:
I have 3 .java file
1) Mapper.java
2) Reducer.java
3) Driver.java
I am trying to compile hadoop mapreduce program at command line using Driver class but it is showing below error
Driver.java:39: error: cannot find symbol
job.setMapperClass(Mapper.class);
^
symbol: class Mapper
location: class Driver
Driver.java:40: error: cannot find symbol
job.setReducerClass(Reducer.class);
How can I solve above error.Below is run method in Driver class
public boolean runnerParsing(String inputPath, String outputPath) throws IOException, ClassNotFoundException, InterruptedException {
Configuration conf = new Configuration();
Job job = new Job(conf, "Parsing");
job.setJarByClass(Driver.class);
job.setOutputKeyClass(Text.class);
job.setOutputValueClass(Text.class);
job.setMapperClass(Mapper.class);
job.setReducerClass(Reducer.class);
//job.setNumReduceTasks(0);
job.setInputFormatClass(TextInputFormat.class);
job.setOutputFormatClass(TextOutputFormat.class);
FileInputFormat.addInputPath(job, new Path(inputPath));
FileOutputFormat.setOutputPath(job, new Path(outputPath));
return job.waitForCompletion(true);
}
解决方案 You will need to compile all java files as below:
javac -classpath /usr/local/hadoop/hadoop-core-1.2.1.jar -d compiled_classes Driver.java Mapper.java Reducer.java
Please note that your classpath value may change slightly depending on how you install Hadoop.
If you need further help, please have a look at this article which might help you:http://www.bigdatatutes.com/getting-started-with-big-data/
这篇关于驱动程序类编译错误 - hadoop Mapreduce的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!