+3  A: 
aioobe
I dislike this answer. You, as a programmer, should know that all good IDEs have a buttton that does what I want this one to do, so it must be possible.
Supuhstar
Oh, wow... well, that's quite the edit, there. Nevermind that last comment. Why don't you recommend this?
Supuhstar
I changed my answer a bit... still though, this is most likely *not* how good IDEs solve it ;)
aioobe
any idea how they do?
Supuhstar
No. Eclipse has it's own compiler... that sort of indicates how complicated their solution could be...
aioobe
A: 
  1. Run the code in a separate JVM. Use debugger interfaces to control that JVM.
  2. Instrument the byte code of the classes you intend to run. Insert cancellation checks at appropriate places, as well as trapping access to global JVM resources.

The second choice is probably an endless source of annoying bugs.

Darron