public static boolean isDebuggerAttached ( ) { final RuntimeMXBean runtimeMXBean = ManagementFactory . getRuntimeMXBean ( ) ; for ( final String arg : runtimeMXBean . getInputArguments ( ) ) { if ( arg . contains ( "-agentlib:jdwp" ) ) { return true ; } } return false ; }
Is a debugger attached to the JVM?