title: NoClassDefFoundError in wordcount program
body: <p>I'm running hadoop wordcount program. But it is giving me error like "NoClassDefFoundError" </p>
  
  <p>command for running :</p>
  
  <pre><code> hadoop -jar /home/user/Pradeep/sample.jar hdp_java.WordCount /user/hduser/ana.txt /user/hduser/prout
    Exception in thread "main" java.lang.NoClassDefFoundError: WordCount
     Caused by: java.lang.ClassNotFoundException: WordCount
      at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
      at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
      Could not find the main class: WordCount. Program will exit.
  </code></pre>
  
  <p>i've created the program in eclipse and then exported as jar file</p>
  
  <p>Eclipse code :</p>
  
  <pre><code>package hdp_java;
  
  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; {
     private final static IntWritable one = new IntWritable(1);
    private Text word = new Text();
  
  public void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
      String line = value.toString();
      StringTokenizer tokenizer = new StringTokenizer(line);
      while (tokenizer.hasMoreTokens()) {
          word.set(tokenizer.nextToken());
          context.write(word, one);
      }
  }
   }
  
    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 val : values) {
          sum += val.get();
      }
      context.write(key, new IntWritable(sum));
  }
    }
  
      public static void main(String[] args) throws Exception {
         Configuration conf = new Configuration();
  
      Job job = new Job(conf, "wordcount");
  
  job.setOutputKeyClass(Text.class);
  job.setOutputValueClass(IntWritable.class);
  
  job.setMapperClass(Map.class);
  job.setReducerClass(Reduce.class);
  
  job.setInputFormatClass(TextInputFormat.class);
  job.setOutputFormatClass(TextOutputFormat.class);
  
  FileInputFormat.addInputPath(job, new Path(args[0]));
  FileOutputFormat.setOutputPath(job, new Path(args[1]));
  
  job.waitForCompletion(true);
  }
  
  }
  </code></pre>
  
  <p>Can anyone tell me where am i wrong?</p>