Debugging the sample program Hellojdb (D:\jdb\HelloJDB) with the JDK's own tool jdb The hellojdb code is as follows:public class Hellojdb{public static void Main (String args[]) {int a,b,c;a = 1;b = 2;c = a + b; System.out.println (c);}} Compile hellojdb:javac-g Hellojdb.java Note: the-G option indicates that debug information is generated, otherwise the locals command cannot be used to view the local variable debug mode run:
java-xdebug-xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 hellojdbjdb Connection:
Jdb-connect Com.sun.jdi.socketattach:hostname=localhost,port=8000-sourcepath d:\jdb Note:-sourcepath Develop the source code, Otherwise, the list directive cannot display the breakpoint at the source code jdb debug:stop at Hellojdb:7 on line seventh under breakpoint Run execution program to breakpoint locals view local variable List view breakpoint where source code next Down execution (step over) step down (step Into) Quit Stop debugging
JDB commissioning of small test sledgehammer