Changing Code on the Fly
Eclipse blurs the line between editing and debugging by letting you modify a running program. You don't have to stop the program—just edit and save it. If possible, Eclipse will compile just the class that was modified and insert it into the running process. This handy feature is called hot code replace.
Tip
If you modify a method that the program is currently executing, the debugger will have to drop to the previous frame and begin that method again from its first line. This doesn't work on the main() method because there is no caller.
Some kinds of changes can be made on the fly and some cannot. Simple things (like fixing an expression formula, changing comments, adding new local variables, adding new statements to an existing method, etc.) should work fine. If for some reason execution cannot continue, you will get an error dialog with the option to continue without making the change, terminate the program, or terminate and restart it from the beginning.
Tip
Hot code replace requires special support from the Java virtual machine that is not present in all versions of Java. It's known to work in Sun's Java Version 1.4.2 and later, but not all vendors support it. If your Java version does not support it, you'll get an error dialog when you try to save.
The debugger has so many features that it's impossible to cover them all here. Part VI covers more advanced topics that impact running and debugging your program, especially in the "Launch Configurations" section. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access