Compiler Error J0101

The type 'identifier' does not inherit from 'Throwable'

The compiler detected an invalid class argument used as an argument in a catch statement. When using a catch statement to handle exceptions, you must define it with a class derived from Throwable as a parameter. Ensure that the class you defined for the catch statement is derived from Throwable and compile again.

The following example illustrates this error:

public class Simple {
   
   public void method1() {
   
      try {
         // do something meaningful
      } catch (String s) {
         // error: 'String' not a subclass
         // of 'Throwable'
      }
   }
}

The following example illustrates the correct way to use the catch statement to trap exceptions:

public class Simple{
   public void method1(int arg1){
      try{
        //do something here
        if (arg1 == 0)
           throw new myException(); //throw a valid exception object
      }
      catch(myException c){ //this is a valid exception object to catch
         //handle exception here
      }
   }
}
class myException extends Throwable{
   //class definition goes here
}