Changing variables in real time while debugging in eclipse?

Using Eclipse, during debugging, you can change the value of variables during project execution for testing purposes.

For example, let's say I have a method that returns the number 5, but for testing purposes I want to output 10 instead. This is not a problem that I came across with it is a little more complicated, but its just to convey my idea.

+48
java debugging eclipse testing
Sep 23 '10 at 12:13
source share
4 answers

You should be able to set a breakpoint, go into debug mode, open variable representations and change the contents of variables here.

enter image description here

+67
Sep 23 '10 at 12:17
source share

You can access variables through the Variables view. There you can right-click on any variable and select " Change value ... ".




Resources:

+19
Sep 23 '10 at 12:17
source share

... and you can do much, much more :-) Just to give you an idea.
You can change the code during debugging, which is hot-swappable and effectively changed (recompiled) in this debugging session. You can run the specified method (for example, after intercepting a breakpoint) several times without restarting debug -> use the drop to frame function in the method stack.

+6
Sep 23 '10 at 12:21
source share

After you change the code, you must save it (cntrl-S) for it to be effective. You will see that your running application responds to code changes after cntrl-S

Hope this works for you. It took me a while to figure this out.

+2
May 24 '12 at 20:27
source share



All Articles