I know about the (jvm) startup options to have the jvm wait until a debugger is attached - this is not what I mean here.
Is it possible from within Java code to also detect attachment of a debugger, so that I could e.g. write a "script" that is doing some stuff and then at a certain point make my app wait for the debugger?