Changing variables in realtime when debugging in eclipse?

JavaEclipseDebuggingTesting

Java Problem Overview


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.

Java Solutions


Solution 1 - Java

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

Solution 2 - Java

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


Resources :

Solution 3 - Java

... 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.

Solution 4 - Java

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.

Solution 5 - Java

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

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionJulioView Question on Stackoverflow
Solution 1 - JavaaioobeView Answer on Stackoverflow
Solution 2 - JavaColin HebertView Answer on Stackoverflow
Solution 3 - JavaGadolinView Answer on Stackoverflow
Solution 4 - JavamartieView Answer on Stackoverflow
Solution 5 - JavaGaurav ShubhamView Answer on Stackoverflow