views:

334

answers:

5

Like firebug for debugging javascript,

is there such a feature in eclipse? or do I need a plugin?

+1  A: 

I believe that what you're looking for are "watch expressions". Just mark the piece of code in the source code view, right-click and select "Watch".

Michael Borgwardt
You can also use the "Display" view to execute any code while you're debugging.
hfernandes
I saw that,but there is no response after I typed "System.out.println('test');" into it.
Shore
How to make it echo some result just under the Display view?
Shore
"watch expressions" works!
Shore
If you highlight the expression in the Display view (which also allows content assist, btw), you can right-click and choose "inspect" (runs the expression and brings up an inspector tree on the result), "execute" (runs the expression), and "display" (runs the expression and prints the result)
Scott Stanchfield
why cant it run without highlight the expression?
Shore
A: 

You can use the Display view to execute commands while debugging. You can find this in Window -> Show View -> Display

mR_fr0g
I run this,but no response in Display tab:System.out.println(path.length);
Shore
Seems need to switch to Console view to see the result,that's un-convenient!
Shore
A: 

you can use the 'Display' view to evaluate expressions in eclipse.

Look under the debug list of views. It is a standard par part of the java tooling so you don't need a plugin

Gareth Davis
But there is nothing echo back,after I type something like "path.length",where path is a String[]
Shore
as far as I remember (not using eclipse at the moment) you click on the run button and the result of the last expression is displayed.
Gareth Davis
But there is no "run" button under Display view..
Shore
Oh,I need to select a row to enable the "run" button..Was that so ?
Shore
I think @banjollity actually has a copy of eclipse open :-) I'm just flandering around in my memory...is now a good time to recommend Intellij
Gareth Davis
+4  A: 

Use the Display view, or a bit quicker: highlight the code you want to run and right-click/Execute or Ctrl+U.

banjollity
Alternatively to "Execute", use Display (Ctrl+Shift+D) or Inspect (Ctrl+Shift+I) to see the result.
zvikico
A: 

You can also create a scrapbook page (a .jpage) file and type your code in there. Then click run. It looked slightly more convenient when I tried it.

wds