title: how to run a class from java jar file on Hadoop?
body: <p>I have a jar file exported from Eclipse (Runnable JAR>>Copy required libraries into a sub folder).</p>
  
  <p>In java if you set the main class in the manifest.xml you can run:</p>
  
  <pre><code>java -jar MyTest.jar arguments
  </code></pre>
  
  <p>if you want to run another main class in the jar file or if you didn't set a main class in the manifest.xml you can run:</p>
  
  <pre><code>java -cp MyTest.jar MyOtherMainClass arguments
  </code></pre>
  
  <p>In Hadoop if main class is set in manifest.xml you can run:</p>
  
  <pre><code>hadoop jar MyTest.jar arguments
  </code></pre>
  
  <p>If you type:</p>
  
  <pre><code>hadoop jar MyTest.jar MyOtherMainClass arguments
  </code></pre>
  
  <p>It will consider MyOtherMainClass as argument (not as a class to run) in the "args" array of the original main class of jar.</p>
  
  <p><strong>Now if you want to run another main class in the jar file what will you type?</strong></p>
  
  <p>I expect something similar to:</p>
  
  <pre><code>hadoop java -cp MyTest.jar MyOtherMainClass arguments
  </code></pre>
  
  <p>but that gives:</p>
  
  <pre><code>Error: Could not find or load main class java
  </code></pre>
  
  <p>Notice: if I remove "hadoop" from "hadoop java -cp MyTest.jar MyOtherMainClass arguments" it will launch normally</p>