'Immediate' window for IntelliJ

JavaDebuggingJakarta EeIntellij Idea

Java Problem Overview


I'm using IntelliJ 9 and I'm curious if there is any IntelliJ equivalent of the Visual Studio 'immediate' debug window. There is selecting the desired expression in the editor, then ALT-F8 to evaluate the expression, but I'd like to be able to write code in a window that interacts with what I am currently debugging (if that's even possible).

Having breakpoints that log messages to the console is helpful, but I'd like to do more than that if I can.

Java Solutions


Solution 1 - Java

Intellij IDEA's Expression Evaluation dialog has a button to enable Code Fragment Mode, which permits multi-statement evaluations. (I'm using version 9.0.2 of the Ultimate Edition.)

Solution 2 - Java

Same as @Noel answer, but some more details. First of all, Expression Evaluation (ALT + F8) can be enabled only in debug mode.

enter image description here

enter image description here

Solution 3 - Java

IntelliJ IDEA 13 Community Edition, Windows:

  1. Go to Debug mode and run the application
  2. Go to Evaluate Expression:

enter image description here

or right click in the editor area:

enter image description here

  1. Go to Code Fragment Mode enter image description here

  2. Type your statements and click on Evaluate enter image description here

Solution 4 - Java

FYI for anyone looking for this in 2019: I tried to do this in IntelliJ IDEA 2019.1 (Ultimate Edition) but couldn't find Code Fragment Mode button in the Expression Evaluation Dialog.

As documented here: It is now the tiny two arrows pointing away from each other diagonally at the end of the expression box.

enter image description here

Solution 5 - Java

You can write code in alt-f8.. but you have to do it only 1 line at a time. If you do a return, your code will return when you hit next (I think). It isn't ideal though...

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
QuestionJon OnstottView Question on Stackoverflow
Solution 1 - JavaNoel AngView Answer on Stackoverflow
Solution 2 - Javaom-nom-nomView Answer on Stackoverflow
Solution 3 - JavaROMANIA_engineerView Answer on Stackoverflow
Solution 4 - JavaAzzamAzizView Answer on Stackoverflow
Solution 5 - JavabwawokView Answer on Stackoverflow