JDB Tutorial
JDB Useful Resources
Selected Reading
- JDB - In Eclipse
- JDB - Exception
- JDB - Stepping
- JDB - Breakpoints
- JDB - Basic Commands
- JDB - Session
- JDB - Options
- JDB - Syntax
- JDB - Installation
- JDB - Introduction
- JDB - Home
JDB Useful Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
JDB - Basic Commands
JDB - 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 pst of commands used for debugging.
Name | Description |
---|---|
help or ? | The most important JDB command; it displays a pst of recognized commands with a brief description. |
run | After starting JDB and setting the necessary breakpoints, you can use this command to start execution and debug an apppcation. |
cont | Continues execution of the debugged apppcation after a breakpoint, exception, or step. |
Displays Java objects and primitive values. | |
dump | For primitive values, this command is identical to print. For objects, it prints the current value of each field defined in the object. Static and instance fields are included. |
threads | Lists the threads that are currently running. |
thread | Selects a thread to be the current thread. |
where | Dumps the stack of the current thread. |
Example
Let us assume we have a sample class called Add for the following examples:
Add.java
pubpc class Add { pubpc int addition( int x, int y) { int z = x + y; return z; } pubpc 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 initiapzing jdb … >run
On executing these commands, you get to see the following output:
Advertisements