74

Like firebug for debugging javascript,

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

10 Answers 10

64

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

Sign up to request clarification or add additional context in comments.

2 Comments

Alternatively to "Execute", use Display (Ctrl+Shift+D) or Inspect (Ctrl+Shift+I) to see the result.
In Eclipse Photon and 2019-03, this view has been renamed to "Debug Shell".
32

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

4 Comments

I run this,but no response in Display tab: System.out.println(path.length);
Seems need to switch to Console view to see the result,that's un-convenient!
select the expression , right click > Display . This shows results in same window
Note: you still have to highlight the command in the Display view and press ctrl+shift+D to execute it. (I typed command; <ENTER> and was wondering why nothing happened).
19

Select the line and press ctrl+shift+D or ctrl+shift+I This will give the result in a popup.

1 Comment

Can we do this without selecting code? I mean executing all code present in Debug Shell by pressing Ctrl + shift + D? And also the output of executed expression is shown in debug shell itself which causes developers to remove output of previously executed expression manually before running next expression. It is very tedious. Eclipse should have IntelliJ style Evaluate expression window.
13

Use the debug shell! Coming from node, I was pretty used to being able to mess with my env variables at any time using node --inspect in chrome, and so it was imperative for me to find the same experience in eclipse without having to use JDB.

To open the debug shell, go to Window → Show View → Debug Shell

After you write the code you wish to run, simply highlight it, right click, and execute (⌘U also works)

Using the debug shell

5 Comments

where does the output get printed?
@vigamage The output is printed to the console tab. Any exceptions however are printed to the Debug Shell tab
@vigamage - If you choose Inspect or Display instead of Execute, you will see the result immediately.
Any idea why I only have Cut, Copy and these sort of things?
@Gqqnbig this is a very late response, but that usually indicates that your program isn't running / it might have crashed (check the console!), or that you aren't on the right tab. Aside from that, no idea
8

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

6 Comments

You can also use the "Display" view to execute any code while you're debugging.
I saw that,but there is no response after I typed "System.out.println('test');" into it.
How to make it echo some result just under the Display view?
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)
@ScottStanchfield Took me about 15-20 minutes to get to understand how to display the value correctly. And you are the only person I found on stack overflow to have described the way it works in Eclipse! Thanks. I was used to the Visual Studio way and following the same in Eclipse made me crazy because there was no output that way.
|
5

I'm currently using Eclipse Photon (v4.8.0). Eclipse changed the "Display" View name to "Debug Shell View". Here, you can execute commands on-the-fly.

1 Comment

It has been renamed in 2019-03 as well.
3

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

4 Comments

But there is nothing echo back,after I type something like "path.length",where path is a String[]
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.
Oh,I need to select a row to enable the "run" button..Was that so ?
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
2

Complementing all the amazing answers, for mac users is cmd + D

Comments

1

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.

Comments

1

Like others say, you use the Display view. But for some variants of Eclipse, it may be named differently. For instance, if you are using Spring Tool Suite as your Eclipse, the View name corresponding to Display view is Debug Shell.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.