title: Exception in thread "main" java.lang.NoSuchMethodException
body: <p>This is my program for word count in Mapreduce and I have created jar file successfully but when I am executing on Hadoop I am facing the following error. </p>
  
  <pre><code>package com.niit;
  
  import java.io.IOException;
  import java.util.StringTokenizer;
  
  import org.apache.hadoop.conf.Configuration;
  import org.apache.hadoop.fs.Path;
  import org.apache.hadoop.io.IntWritable;
  import org.apache.hadoop.io.LongWritable;
  import org.apache.hadoop.io.Text;
  import org.apache.hadoop.mapreduce.Job;
  import org.apache.hadoop.mapreduce.Mapper;
  import org.apache.hadoop.mapreduce.Reducer;
  import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
  import org.apache.hadoop.mapreduce.lib.input.TextInputFormat;
  import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
  import org.apache.hadoop.mapreduce.lib.output.TextOutputFormat;
  
  public class WordCount {
      public static class Map extends Mapper&lt;LongWritable,Text,Text,IntWritable&gt; {
          public void map(LongWritable key, Text value,Context context) throws IOException,InterruptedException{
              String line = value.toString();
              StringTokenizer tokenizer = new StringTokenizer(line);
              while (tokenizer.hasMoreTokens()) {
                  value.set(tokenizer.nextToken());
                  context.write(value, new IntWritable(1));
              }
          }
      }
  
      public static class Reduce extends Reducer&lt;Text,IntWritable,Text,IntWritable&gt; {
          public void reduce(Text key, Iterable&lt;IntWritable&gt; values,Context context) throws IOException,InterruptedException {
              int sum=0;
              for(IntWritable x: values) {
                  sum+=x.get();
              }
              context.write(key, new IntWritable(sum));
          }
      }
  
      public static void main(String[] args) throws Exception {
  
          Configuration conf= new Configuration();
          Job job = new Job(conf,"My Word Count Program");
          job.setJarByClass(WordCount.class);
          job.setMapperClass(Map.class);
          job.setReducerClass(Reduce.class);
          job.setOutputKeyClass(Text.class);
          job.setOutputValueClass(IntWritable.class);
          job.setInputFormatClass(TextInputFormat.class);
          job.setOutputFormatClass(TextOutputFormat.class);
          Path outputPath = new Path(args[1]);
          //Configuring the input/output path from the filesystem into the job
          FileInputFormat.addInputPath(job, new Path(args[0]));
          FileOutputFormat.setOutputPath(job, new Path(args[1]));
          //deleting the output path automatically from hdfs so that we don't have to delete it explicitly
          outputPath.getFileSystem(conf).delete(outputPath);
          //exiting the job only if the flag value becomes false
          System.exit(job.waitForCompletion(true) ? 0 : 1);
      }
  }
  </code></pre>
  
  <p>and this is the error message I'm getting:</p>
  
  <pre><code>Command: yarn jar WordCount-1.0.jar com.niit.WordCount /usr/lib/hadoop-2.2.0/workspace/input/simple.txt /usr/lib/hadoop-2.2.0/workspace/output
      Exception in thread "main" java.lang.NoSuchMethodException: com.niit.WordCount.main([Ljava.lang.String;)
              at java.lang.Class.getMethod(Class.java:1665)
              at org.apache.hadoop.util.RunJar.main(RunJar.java:206)
  </code></pre>