How do you turn the debug on and off within your Java program ? How do you turn the debug on and off without recomipiling the java program?
A Java program can be debugged simply by right clicking on the Java editor class file from Package explorer. Select Debug As → Java Application or use the shortcut Alt + Shift + D, J instead. Either actions mentioned above creates a new Debug Launch Configuration and uses it to start the Java application.
The debugger is started with the jdb command; it attaches to the JVM using JPDA. The JVM starts up, but suspends execution before it starts the Java application.
The Java Debugger, jdb, is a simple command-line debugger for Java classes. It is a demonstration of the Java Platform Debugger Architecture that provides inspection and debugging of a local or remote Java Virtual Machine.
A setting to the Java virtual machine allows debuggers e.g. jdb to attach. See http://docs.oracle.com/javase/7/docs/technotes/tools/windows/jdb.html
This is the important bit:
Running MyClass in a JVM with debugging enabled:
java -agentlib:jdwp=transport=dt_shmem,address=jdbconn,server=y,suspend=n MyClass
Using the jdb debugger
jdb -attach jdbconn
Note: These option settings are for a connection JVM <-> debugger on the local machine via shared memory, other useful settings allow to connect to a JVM on a remote machine via network sockets.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With