I need to stop debugger applications from debugging my code. For this, i am using the following code in the constructor of my classes:
RuntimeMXBean RuntimemxBean = ManagementFactory.getRuntimeMXBean();
java.util.List<String> arguments = RuntimemxBean.getInputArguments();
//System.setErr(null);
for ( String str : arguments)
{
System.out.println("\n"+str);
if ( str.contains("jdwp") || str.contains("debug"));
System.exit(1);
}
Please confirm me if this code will be enough or still there needs to be a smarter way(which think there should be!) to do it... I have worked out this code with debuggers like JDB, Eclipse IDE, Netbeans.