简体   繁体   中英

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.

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.

在此输入图像描述

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


Resources :

... 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 (eg after catching breakpoint) few times without rerunning debug -> use drop to frame feature on method stack.

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM