Reputation: 577
This is a minor annoyance for me that keeps coming up. When I'm debugging a program I can see variables in the immediate scope, but I can't see variables which are global, static, or variables inherited by 'this' class. The only way I know how to get these values for testing is to create a dummy variable to store the variable I want within scope of a given function, which isn't efficient or elegant.
Is there an easier way to see the value of any/all of the three variable types I mentioned while stepping through the debugger?
Thanks
Upvotes: 8
Views: 15358
Reputation: 20371
Expanding the entry for this
in the Variables
view in the Debug Perspective
should let you view all of those (non-static) members already, by default.
To view constants and static members, in the Variables
view's menu (opened by clicking the little down arrow at the top right of the view), choose Java > Show Static Variables
or Show Constants
Upvotes: 17
Reputation: 7335
In the Debug Perspective, open the Variables view, click on the downward pointing arrow at the top right of the pane and select Java / Show Static Variables
Upvotes: 2
Reputation: 25150
You can use the Expression View to watch an arbitrary expression, including static and global variables.
Another handy view is the Displays View, which allows you to execute arbitrary code.
Upvotes: 6