Why are some methods in Java not caught by Catch(Exception ex). This is code is completely failing out with an unhandled exception. (Java Version 1.4).
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);
}
I get a "Exception in thread "main" java.lang.NoSuchMethodError "
But this works
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);
}
I get "Caught NoSuchMethodError java.lang.NoSuchMethodError: "
I thoguht catching exceptions would catch all exceptions? How can I catch all exceptions in java?