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


If you find this article useful, consider making a small donation
to show your support for this Web site and its content.

Written and compiled by Réal Gagnon ©1998-2012
[ home ]