Install Groovy on Ubuntu
Ubuntu ships Groovy in its own repository, which is the shortest install. The package follows the release of the distribution and is often one or two versions behind; the second half of this page installs the current release with SDKMAN. This is the Ubuntu page of the install overview.
Install with apt
Refresh the package list, then install the JDK and Groovy in one command:
sudo apt update
sudo apt install -y default-jdk groovy
-y answers the confirmation prompt, and default-jdk brings the javac that groovyc needs. The install puts groovy in /usr/bin, so no environment variable is required.
Check the version
One command proves both halves: the launcher runs, and it found a JDK.
groovy --version
The line names the Groovy version, the JVM and the vendor. A message about a missing JAVA_HOME means the JDK package did not arrive: install default-jdk and try again. This container is Alpine, so the apt command was not run here.
A newer release with SDKMAN
SDKMAN installs JVM tools side by side in the home folder, which gives the current Groovy without touching the system packages:
curl -s "https://get.sdkman.io" | bash
source "$HOME/.sdkman/bin/sdkman-init.sh"
sdk install groovy
sdk list groovy prints the versions that are available and sdk use groovy 5.0.8 switches to one for the current shell. SDKMAN downloads from the network, which this container does not have, so the three commands are shown and not run.
Related
- Install Groovy on Rocky Linux: the next system page.
- Install Groovy on Windows 11: the archive install.
- Groovy in Docker: the same version without an install.
Article author: Arthur Isaev