Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Watching variables contents in Eclipse IDE

How can I watch the contents of several variables (for example, TreeSet's) simultaneously? I can watch contents of one TreeSet, clicking on it in "Variables" window, but I have no idea how to do that for several variables.

like image 824
karlicoss Avatar asked Apr 14 '11 14:04

karlicoss


People also ask

How do I view variables in Eclipse?

Variables/Expression view – Shows the declared variables and their values. Press Ctrl+Shift+d or Ctrl+Shift+i on a selected variable or expression to show its value. You can also add a permanent watch on an expression/variable that will then be shown in the Expressions view when debugging is on.

How do you watch a variable in Java?

Setting a Watch on a Variable, Field, or Other Expression To set a watch on an identifier such as a variable or field, right-click the variable or field in the Source Editor and choose New Watch. The identifier is then added to the Watches window. To create a watch for another expression: Choose Run | New Watch.

How can you see variable references while debugging in Eclipse?

While debugging you can use the "Display" window where you can write pieces of code and "execute" them with inspect (highlight the code -> right click -> inspect). In that window you have access to all variables of the breakpoint's context.

How do I open the watch window in Eclipse?

In Eclipse that view is called Expressions - for watch expressions. It opens regularly with the Debug view, but you can open it using "Window"->"Show view"->"Other"->"Debug"->"Expressions".


2 Answers

You can use Expressions windows: while debugging, menu window -> Show View -> Expressions, then it has place to type variables of which you need to see contents

like image 112
Phuong Avatar answered Oct 12 '22 17:10

Phuong


You can add a watchpoint for each variable you're interested in.

A watchpoint is a special breakpoint that stops the execution of an application whenever the value of a given expression changes, without specifying where it might occur. Unlike breakpoints (which are line-specific), watchpoints are associated with files. They take effect whenever a specified condition is true, regardless of when or where it occurred. You can set a watchpoint on a global variable by highlighting the variable in the editor, or by selecting it in the Outline view.

like image 36
Matt Ball Avatar answered Oct 12 '22 17:10

Matt Ball