IntelliJ IDEA 2019.2 Help

Work with Groovy Interactive Console

You can open an interactive Groovy console in any project including a Java one and use the console as a temporary file to write and evaluate your code.

If dependencies in your project contain a Groovy library then the specified Groovy library is used to launch the Groovy console. If the dependencies do not contain a Groovy library then the bundled Groovy library will be used.

  1. From the main menu, select Tools | Groovy Console.

  2. If you have more than one module in your project, click the project's name on the console toolbar and select a module from the list to change a classpath for the console.
    Groovy Module Console

    The Groovy console starts in a separate tab in the editor.

    groovy editor console

Perform different actions inside the Groovy console

  • You can enter code, the coding assistance is available as you type, or paste code from a different file. Press Ctrl+Enter or click icons toolwindows toolWindowRun svg to execute code and view the results in the Run tool window.

    Groovy console and Run tool window

  • You can refer to a class from the Groovy console. Type the name of the class you need, select it and press Ctrl+B to jump to its declaration.

  • If you have an import statement in your code, you can run a partial selection of code omitting the import statement. The Groovy console will include the omitted part during the execution.

Last modified: 28 August 2019

See Also