Julio
Julio

Reputation: 6368

Changing variables in realtime when debugging in eclipse?

Using Eclipse, when debugging is it possible to change the value of variables during runtime of a project for testing purposes.

For example, say I have a method that returns the number 5 but for testing purposes i want to output 10 instead. This isn't the problem I'm facing its a little more complex but its just to get my idea across.

Upvotes: 57

Views: 67744

Answers (5)

Gaurav Shubham
Gaurav Shubham

Reputation: 21

Run your application in debug mode then go to variables window. select the parameter then change values according to your requirements. then save (ctrl+s). and go ahead with your changes. Hope this will help.

If variables window is missing. then goto eclipse window->show views->variables

Upvotes: 2

aioobe
aioobe

Reputation: 421020

You should be able to set a break-point, go into debug mode, open the variables views and here change the content of the variables.

enter image description here

Upvotes: 73

martie
martie

Reputation: 51

After you have changed the code you have to save it (cntrl-S) to make it effective. You will see your running application respond to the code-change after the cntrl-S

I hope this works for you. it took me some time to figure this out.

Upvotes: 5

Colin Hebert
Colin Hebert

Reputation: 93177

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


Resources :

Upvotes: 21

Gadolin
Gadolin

Reputation: 2686

... and you can do much, much more:-) Just to give you and idea.
You may change the code during debug which is hot swapped and is effectively changed (recompiled) in given debug session. You may run given method run (e.g. after catching breakpoint) few times without rerunning debug -> use drop to frame feature on method stack.

Upvotes: 7

Related Questions