How to debug a Java program without using an IDE?
java
Solution
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.
Problem
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?