title: Getting "Exception in thread "main" java.lang.NoSuchMethodError: main"?
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/2496073/exception-in-thread-main-java-lang-nosuchmethoderror-main">Exception in thread &ldquo;main&rdquo; java.lang.NoSuchMethodError: main</a>  </p>
  </blockquote>
  
  
  
  <p>I am fairly new to Java, and I am unable to figure out why I am getting <code>NoSuchMethodError: main</code> when I execute the following code. I am not sure what does the <code>NoSuchMethodError</code> is pertaining to. It looks like I have everything right. Please help me out here. Thanks a lot.</p>
  
  <pre><code>public class ThreadExample1 extends Thread 
   {
      static String[] msg = {"Java", "programming", "is", "the", "best"};
      public ThreadExample1(String id) 
      {
         super(id);
       }
      @Override
      public void run() 
          {
           try 
             {
               Output.displayList(getName(), msg);
              } 
      catch (InterruptedException ex) 
          {
  
          }
      }
    }
  
  class Output 
   {
    public static void displayList(String name, String list[]) throws InterruptedException 
     {
       for (int i = 0; i &lt; list.length; i++) 
      {
            Thread.currentThread().sleep((long) (3000 * Math.random()));
            System.out.println(name + list[i]);
           }
      }
     public static void main(String[] args) 
      {
           ThreadExample1 thread1 = new ThreadExample1("thread1: ");
           ThreadExample1 thread2 = new ThreadExample1("thread2: ");
           thread1.start();
           thread2.start();
           boolean t1IsAlive = true;
           boolean t2IsAlive = true;
           do 
            {
            if (t1IsAlive &amp;&amp; !thread1.isAlive()) 
              {
                t1IsAlive = false;
                System.out.println("t1 is dead.");
               }
            if (t2IsAlive &amp;&amp; !thread2.isAlive()) 
              {
                t2IsAlive = false;
                System.out.println("t2 is dead.");
                }
             }while (t1IsAlive || t2IsAlive);
       }
  }
  </code></pre>