omg
omg

Reputation: 139872

How to execute some function in eclipse while debugging a java program?

Like firebug for debugging javascript,

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

Upvotes: 74

Views: 88752

Answers (10)

Sumiya
Sumiya

Reputation: 337

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.

Upvotes: 1

Ronak Shah
Ronak Shah

Reputation: 1058

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

Upvotes: 13

Mr. Butterworth
Mr. Butterworth

Reputation: 145

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.

Upvotes: 5

Alberto Alegria
Alberto Alegria

Reputation: 1060

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

Upvotes: 2

Vinoj John Hosan
Vinoj John Hosan

Reputation: 6863

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

Upvotes: 19

wds
wds

Reputation: 32283

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.

Upvotes: 1

banjollity
banjollity

Reputation: 4540

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

Upvotes: 64

Gareth Davis
Gareth Davis

Reputation: 28059

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

Upvotes: 3

mR_fr0g
mR_fr0g

Reputation: 8722

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

Upvotes: 32

Michael Borgwardt
Michael Borgwardt

Reputation: 346317

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

Upvotes: 8

Related Questions