Reputation: 1314
I am new to Hadoop.I have three separate files with map,reduce and mapreduce code.The mapper and reducer files got compiled but the main class throws cannot find symbol error in the setmapperclass and setreducerclass methods.This is the code for main:
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
import org.apache.hadoop.mapreduce.Mapper;
public class MaxTemperature {
public static void main(String[] args) throws Exception {
if (args.length != 2) {
System.err.println("Usage: MaxTemperature <input path> <output path>");
System.exit(-1);
}
Job job = new Job();
job.setJarByClass(MaxTemperature.class);
job.setJobName("Max temperature");
FileInputFormat.addInputPath(job, new Path(args[0]));
FileOutputFormat.setOutputPath(job, new Path(args[1]));
job.setMapperClass(MaxTemperatureMapper.class); //error cannot find symbol
job.setReducerClass(MaxTemperatureReducer.class); //error cannot find symbol
job.setOutputKeyClass(Text.class);
job.setOutputValueClass(IntWritable.class);
}}
The version of hadoop is use is 2.5.1 and I compile it using
hdfs com.sun.tools.javac.Main /usr/local/hadoop/share/hadoop/mapreduce/MaxTemperature.java
I used the same command to compile mapper and reducer programs.
Upvotes: 0
Views: 1631
Reputation: 21
You can compile all the three files together like below:
javac -cp hadoop-common-0.21.0.jar:hadoop-core-1.1.2.jar:commons-cli-1.3.1.jar:com.google.guava_1.6.0.jar:hadoop-mapred-0.21.0.jar FacebookCount.java FacebookMapper.java FacebookReducer.java -d /usr/local/com/subu/
Upvotes: 2