Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java Eclipse evaluate expression

Is it possible to evaluate a expression in Eclipse similar to IntelliJ. Where you can dynamically type code and the result will be displayed during debug?. I know it does something similar "Display" but you need to highlight code that has been written (so you cant write any new code unless you re-compile).

Perhaps there are plugins that i could use?. I have just started using eclipse

like image 509
Rory Lester Avatar asked May 06 '14 06:05

Rory Lester


People also ask

How do you use Watch expression in Eclipse?

Solution. Highlight the variable or expression while debugging, right-click it, and select Watch, or select Run→ Watch. The variable or expression, along with its value, will appear in the Expressions view from then on.

What is debug shell in Eclipse?

When we start the program in debug mode, Eclipse will prompt with an option to switch to the Debug perspective. The Debug perspective is a collection of some useful views that help us visualize and interact with the debugger. We can also switch to the Debug perspective manually at any time.

How do I use debug mode in Eclipse?

A Java program can be debugged simply by right clicking on the Java editor class file from Package explorer. Select Debug As → Java Application or use the shortcut Alt + Shift + D, J instead. Either actions mentioned above creates a new Debug Launch Configuration and uses it to start the Java application.


1 Answers

There is a Display view as well that can do exactly what you want. Go to Window > Show view > Display (or Other... if the Display view is not there. In the Display view, you can type any code you want during debug (content assist is available). The current objects and variables are also available to use. After you wrote your code, you have to highlight it, right click and select Execute or hit CTRL-U. You may play around with the other possible actions as well.

Besides that, you can also write in the source code during debug and evaluate it using Display as you mentioned, if you have the source for the class you are debugging.

like image 60
Sleeper9 Avatar answered Sep 29 '22 07:09

Sleeper9