There are two common ways to install Groovy.
The Groovy binary can be downloaded on the download page of the Groovy website. You can unpack archive and add path to
%GROOVY_HOME%/bin/groovy.bat to the PATH system environment variable, where %GROOVY_HOME% is the directory where Groovy is unpacked.
The other option is to use SDKMAN. This option has grown quickly in popularity, and makes managing multiple versions of Groovy very simple. It also supports other applications in the "GR8" ecosphere. This option works very well natively on Linux and Mac, but requires Cygwin on Windows.
Following the instructions on the Groovy download page, you can take the following steps to install SDKMAN.
$ curl -s get.sdkman.io | bash
Once SDKMAN is installed, you now have access to the
sdk command. With this command you can do many useful things.
$ sdk install groovy
This will install the latest version of Groovy.
List versions of Groovy
$ sdk ls groovy
This allows you to run a Linux style
ls command on the Groovy software, listing all of the available options. There is an
* next to each installed version, and a
> to indicate your current versions.
Switch versions of Groovy
$ sdk use groovy 2.4.7
This will change the current version of Groovy to 2.4.7. If you have other versions installed, you can switch to any of those.
You can list the current version of groovy with the
groovy -version command.
The initial name of SDKMAN was GVM and posh-gvm is a port of GVM for the Windows Powershell. So, if you develop on a Windows machine and don't want to use SDKMAN on Cygwin, posh-gvm is for you. It works the same as SDKMAN, but instead of
sdk, the command is
PS C:\Users\You> gmv install groovy
will install groovy through posh-gvm on your Windows machine.