>> - Basic Commands
This chapter takes you through the basic commands of JDB. After launching a session, these commands are used for debugging a program.
The following is the list of commands used for debugging.
Example
Let us assume we have a sample class called Add for the following examples:
Add.java
public class Add { public int addition( int x, int y) { int z = x + y; return z; } public static void main( String ar[ ] ) { int a = 5, b = 6; Add ob = new Add(); int c = ob.addition(a,b); System.out.println("Add: " + c); } }
Compile this class Add.java using the following command:
\>javac Add.java
Run
This command executes the main class file, which is added to JDB for debugging. Execute the following commands to run the Add class.
\>jdb Add initializing jdb … >run
On executing these commands, you get to see the following output:
Advertisements