Skip to content
AgileLogics
3 min read

Setting Up Your Environment

Prerequisites: Installing Groovy

Editor

  • IntelliJ IDEA (the free Community Edition is enough) has the best Groovy support: completion, refactoring, debugging, Gradle, and Spock.
  • Visual Studio Code with a Groovy extension gives syntax highlighting and basic completion — fine for scripts, Jenkinsfiles, and build files.

groovysh — the interactive shell

Run groovysh to get an interactive prompt (a REPL), where each line runs as soon as you press Enter:

$ groovysh
groovy> 1 + 2
3
groovy> 'groovy'.toUpperCase()
GROOVY
groovy> /exit

The prompt style differs slightly between versions; older versions use :exit instead of /exit.

groovyConsole — a small GUI

groovyConsole opens a window with an editor at the top and output at the bottom. Press Ctrl + R (or Cmd + R) to run the script. It's a comfortable way to experiment with longer snippets.

Running files

groovy hello.groovy            # compile in memory and run
groovy hello.groovy a b c      # pass command-line arguments
groovy -e "println 6 * 7"      # run a one-liner
groovyc Hello.groovy           # compile to .class files