title: hadoop submits job with class name, why is job.setJarByClass() necessary?
body: <p>E.g. I've got a hadoop word-count program(from internet)
  , WordCount.java:</p>
  
  <pre><code>public static class WordCount{
      public static void main(String[] args)throws Exception{
      ....
          Job job = Job.getInstance(new Configuration(), "word count");
          job.setJarByClass(WordCount.class); //Why?
      }
  }
  </code></pre>
  
  <p>Ccompile it into a jar and submit it to yarn like this:</p>
  
  <pre><code>hadoop jar wordcount.jar WordCount [input-hdfs] [output-hdfs]
  </code></pre>
  
  <p>In this command, we have specified:</p>
  
  <p>(1) jar name (2) class name</p>
  
  <p>As long as </p>
  
  <ol>
  <li><p>hadoop already know from its command line "WordCount" is the class name from wordcount.jar. </p></li>
  <li><p>The public class of WordCount.java is always WordCount, this is java standard, right?</p></li>
  </ol>
  
  <p>Then what's the point of calling</p>
  
  <pre><code>setJarByClass(WordCount.class)
  </code></pre>
  
  <p>Seems to me it's redundant. Why is this statement required? Thanks</p>