How can I change the value of a variable while debugging Java code in NetBeans 7.1?
Asked Answered
F

2

11

I have set a breakpoint that allows me to see the value in a field on an object. I'd like to change the value then continue execution, but then I try to edit the value from the variables view, the value field is grayed-out. Is there any way to change variable values while debugging?

Florin answered 31/1, 2012 at 21:36 Comment(2)
Tak a look here cs.uga.edu/~shoulami/sp2009/cs1301/tutorial/…Ezra
Updated link for above comment: web.archive.org/web/20110621082236/http://www.cs.uga.edu/…Bashuk
A
21

It is also possible to change the value of the primitive variables and Strings in-place in the Value column of Variables window. To change values of Object variables, you can use "Evaluate Expression..." under menu Debug option (Ctrl+F9).

Akeylah answered 30/8, 2012 at 13:45 Comment(1)
CTRL + F9 !! What i was looking forSpiraea
U
4

You can apply your code changes through your debug session simply by selecting Apply Code Changes under the Debug menu. Thanks to this feature, you can debug code, make fixes, and then continue debugging without restarting the application.

If you want to apply your code changes automatically when you save changes to JAVA code while debugging, from the the "Tools" menu, you select "Options", then click the "Java Debugger" tab, then check the "Apply code changes after save" and then press "OK".

Unaesthetic answered 31/1, 2012 at 21:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.