Install Groovy on Windows 11

Windows has no package for the current Groovy, so the install is the binary archive of groovy.apache.org: a zip, a folder, and two environment variables. This page is the Windows one of the install overview.

Install a JDK 21

Groovy 5 needs Java 17 or newer. Install a JDK 21 first, for example the Temurin build, and open a new PowerShell window so the installer's PATH change is visible. Check it:

java -version

The command must print a version and, for a JDK, must be the one whose folder also holds javac. The Java install pages cover the JDK itself.

Unpack the archive

Download the binary zip of Groovy 5 and expand it to a folder without spaces in its path, such as C:\groovy. The archive already contains a folder named after the version, so move or rename it so that C:\groovy\bin\groovy.bat exists.

groovy.bat is the Windows launcher; the shell scripts next to it are for WSL and Git Bash.

GROOVY_HOME and PATH

Open System Properties, Environment Variables, and add two entries for the user:

The same in PowerShell, for the current user, which is faster than the dialog and easier to undo:

[Environment]::SetEnvironmentVariable('GROOVY_HOME', 'C:\groovy', 'User')
$path = [Environment]::GetEnvironmentVariable('Path', 'User')
[Environment]::SetEnvironmentVariable('Path', "$path;C:\groovy\bin", 'User')

Close the window and open a new one: a process reads its environment once, at start.

Check the version

In a new PowerShell window:

groovy --version

The answer is one line, and this container prints the same shape:

Groovy Version: 5.0.8 JVM: 21.0.13.1 Vendor: Alpine OS: Linux

On Windows the Vendor and OS fields name your JDK and Windows 11; the version numbers are those of your archive and your JDK. The command was not run on Windows for this page: this container is Alpine Linux and has no PowerShell.

Groovy in WSL

A Windows Subsystem for Linux distribution follows the Ubuntu page instead, with the Linux folder layout and the Linux launcher. A project that builds on both sides keeps its scripts in the WSL file system, not under /mnt/c, where every file read crosses the Windows layer and a build becomes slow.

Related

Article author: Arthur Isaev