Compiler Error J0165

Cannot throw exception 'identifier' from method 'identifier' -- it is not a subclass of any exceptions thrown from overridden method 'identifier'

The compiler detected an overridden method attempting to throw more exceptions than the method it overrides. In Java, an override method cannot be declared to throw more exceptions than the overridden method. Either change the exception thrown to one that the base class throws, or change the base class declaration to throw the exception type that the subclass needs to throw.

The following example illustrates this error:

class ExceptionA extends Exception {
   // do something meaningful
}

class ExceptionB extends Exception {
   // do something meaningful
}

class AnotherClass {
   
   public void method1() throws ExceptionA {
      // do something meaningful
   }
}

public class Simple extends AnotherClass {
   
   public void method1() throws ExceptionA, ExceptionB {
      // error: cannot throw greater than 
      // one exception here
   }
}