Driver class compilation error - hadoop Mapreduce

2019-09-01 07:13发布

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);

     }

2条回答
走好不送
2楼-- · 2019-09-01 07:42

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/

查看更多
闹够了就滚
3楼-- · 2019-09-01 07:43

This is what i think:

  • You don't have Mapper/Reducer stored in Mapper.java/Reducer.java.
  • You have mapper/reducer class in another package

Can you add your mapper and reducer class as well to question?

查看更多
登录 后发表回答