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

JavaEclipseDebugging

Java Problem Overview


Like firebug for debugging javascript,

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

Java Solutions


Solution 1 - Java

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

Solution 2 - Java

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

Solution 3 - Java

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

Solution 4 - Java

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

Solution 5 - Java

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

Solution 6 - Java

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.

Solution 7 - Java

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

Solution 8 - Java

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

Solution 9 - Java

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.

Solution 10 - Java

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.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionomgView Question on Stackoverflow
Solution 1 - JavabanjollityView Answer on Stackoverflow
Solution 2 - JavamR_fr0gView Answer on Stackoverflow
Solution 3 - JavaVinoj John HosanView Answer on Stackoverflow
Solution 4 - JavaRonak ShahView Answer on Stackoverflow
Solution 5 - JavaMichael BorgwardtView Answer on Stackoverflow
Solution 6 - JavaMr. ButterworthView Answer on Stackoverflow
Solution 7 - JavaGareth DavisView Answer on Stackoverflow
Solution 8 - JavaAlberto AlegriaView Answer on Stackoverflow
Solution 9 - JavawdsView Answer on Stackoverflow
Solution 10 - JavaSumiyaView Answer on Stackoverflow