Detect if running in a debug modeTag(s): Environment


If you want to detect if your program is running in debug mode (ex. Eclipse).
public class Test {
 public static void main(String args[]) {
   boolean isDebug =
     java.lang.management.ManagementFactory.getRuntimeMXBean().
         getInputArguments().toString().indexOf("-agentlib:jdwp") > 0;
   System.out.println("In debug : " + isDebug);
 }
}

blog comments powered by Disqus