title: JUnit help wanted: Exception in thread "main" java.lang.NoSuchMethodError: main
body: <p>I have two files:</p>
  
  <p>Calc.java</p>
  
  <pre><code>public class Calc {
   public int add(int a, int b) {
    return a + b;
   }
   public int subtract(int a, int b) {
    return a - b;
   }
  }
  </code></pre>
  
  <p>and TestCalc.java</p>
  
  <pre><code>import org.junit.* ;
  import static org.junit.Assert.* ;
  
  public class TestCalc {
  
    Calc c = new Calc();
  
    @Test
    public void testSum() {
      // 6 + 9 = 15
      int expected = 15;
      int actual = c.add(6, 9);
      assertEquals("adding 6 and 9", expected, actual);
    }
  
    @Test
    public void testSubstr() {
      // 18 - 3 = 15
      int expected = 15;
      int actual = c.subtract(18, 3);
      assertEquals("subtracting 3 from 18", expected, actual);
      }
    }
  </code></pre>
  
  <p>They compile without errors:</p>
  
  <pre><code>javac -cp .:junit-4.11.jar TestCalc.java
  javac -cp .:junit-4.11.jar Calc.java
  </code></pre>
  
  <p>But when I'm trying to run, I'm getting an error:</p>
  
  <pre><code>java -cp .:junit-4.11.jar TestCalc
  
  Exception in thread "main" java.lang.NoSuchMethodError: main
  </code></pre>
  
  <p>Could someone, please, explain why? And how to fix that?</p>