JDB Exception Handling

JDB Exception Handling with Introduction, JDB Tutorial, Architecture, Installation, Expression, Connection, Commands, Example, Breakpoint, Stepping, Options, Exception Handling etc.

JDB Exception Handling

JDB Exception Handling

Exception is an event that disrupts the normal flow of the program. Thus, it is important to handle these exceptions.

Like Java, Java Debugger (JDB) is also capable to handle these exceptions. The JDB catch command caught the exceptions at runtime.

Example of Exception Handling

In this example, we will handle arithmetic exception through JDB command on console.


  1. public class JException  
  2. {  
  3. int div(int a,int b)  
  4. {  
  5. return a/b;  
  6. }  
  7. public static void main( String...jtp)  
  8. {  
  9. JException obj=new JException();  
  10. System.out.println(obj.div(10,0));  
  11. }  
  12. }  

Compile the above program and create a JDB session.

After the execution of program the following exception occurs:

Now, catch this exception by the following command: -

  1. >catch java.lang.ArithmeticException  

The following message will display on your console: -

Set all java.lang.ArithmeticException

Continue the execution by the following command: -

  1. >cont