JDB Example

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

JDB Example

JDB Example

In this section, we will learn how to initialize and run java debugger with the help of an example.

  • Create a simple java program


  1. public class JDBExample  
  2. {  
  3. public static void main(String...kk)  
  4. {  
  5. int a=10b=20;  
  6. int c=a+b;  
  7. System.out.println("Sum of two number : "+c);  
  8. }  
  • Open command prompt and compile your main class with the following command:-

javac JDBExample.java  

  • Now, initialize Java debugger with the following command:-

jdb JDBExample  

  • The next task is to run java class. So, run the main class with the below command:-


After the execution of command, the following result will be generated on the console.

Note - After displaying the result, the application will exited automatically.