title: Java exception not caught
body: <p>Why are some exceptions in Java not caught by <code>catch (Exception ex)</code>?  This is code is completely failing out with an unhandled exception.  (Java Version 1.4).</p>
  
  <pre><code>public static void main(String[] args) {
      try {
          //Code ...
      } catch (Exception ex) {
          System.err.println("Caught Exception");
          ex.printStackTrace();
          exitCode = app.FAILURE_EXIT_CODE;
      }
      finally {
          app.shutdown();
      }
      System.exit(exitCode);
  }
  </code></pre>
  
  <p>I get a <code>Exception in thread "main" java.lang.NoSuchMethodError</code></p>
  
  <p>But this works</p>
  
  <pre><code>public static void main(String[] args) {
      int exitCode = app.SUCCESS_EXIT_CODE;
      try {
          //Code ...
      } catch (java.lang.NoSuchMethodError mex){
          System.err.println("Caught NoSuchMethodError");
          mex.printStackTrace();
          exitCode = app.FAILURE_EXIT_CODE;
      } catch (Exception ex) {
          System.err.println("Caught Exception");
          ex.printStackTrace();
          exitCode = app.FAILURE_EXIT_CODE;
      }
      finally {
          app.shutdown();
      }
      System.exit(exitCode);
  }
  </code></pre>
  
  <p>I get <code>Caught NoSuchMethodError java.lang.NoSuchMethodError:</code></p>
  
  <p>I thought catching exceptions would catch all exceptions?  How can I catch all exceptions in java?</p>