Java Debugger (JDB)
Java Debugger (JDB)
JDB(Java Debugger)
"jdb": A command line tool that allows you to debug a Java application
interactively with in a command line mode.
Syntax:
commands interactively.
Without the "-launch" option, "jdb" will not start the main() method of the specified
class.
"stop in" command sets a breakpoint at the beginning of the specified method. See
"run" command starts a new JVM process with run your application in debug mode.
"next" command executes only the current statement of the debugged application.
"cont" command resumes the execution to the end or the next breakpoint.
To test the debugger, in the the following simple Java
application, Hello.java:
class Hello {
public static void main(String[] a) {
System.out.println("Hello world!");
}
}
-launch option
1)C:\jdb -launch Hello
Set uncaught java.lang.Throwable
Set deferred uncaught java.lang.Throwable
Initializing jdb ...
2) main[1] cont
Hello world!
2) C:\jdb Hello
Initializing jdb ...
3) stop in Hello.main
Deferring breakpoint Hello.main.
It will be set after the class is loaded.
4) run
run Hello
Set uncaught java.lang.Throwable
Set deferred uncaught java.lang.Throwable
VM Started: Set deferred breakpoint Hello.main
Breakpoint hit: "thread=main", Hello.main(), line=3
bci=0
3 System.out.println("Hello world!");
(5) main[1] next
Hello world!
Step completed: "thread=main", Hello.main(), line=4
bci=8
}
(6) main[1] cont
The application exited