Skip to content

How to Install Apache Groovy on Ubuntu Linux

Richard
Written by
Richard
Aug 9, 2020 Updated Jun 20, 2026 3 min read
How to Enable or Disable Microsoft Defender Cloud Protection

You install Apache Groovy on Ubuntu Linux to run a versatile, object-oriented, dynamic programming language alongside your Java applications.

Apache Groovy is a robust language built for the Java Virtual Machine (JVM), enhancing productivity with its expressive syntax and Java compatibility.

This guide shows you how to install Apache Groovy, specifically version 4.0.1, on Ubuntu 22.04 and 20.04 LTS using common package management tools.

Follow these straightforward steps to get Groovy up and running on your Ubuntu system for scripting and development.

⚡ Quick Answer

Update your system with `sudo apt update`, install OpenJDK 8 with `sudo apt install openjdk-8-jdk`, then install SDKMAN and Groovy using `curl -s get.sdkman.io | bash` followed by `sdk install groovy`.

Prepare Ubuntu

Before you install Apache Groovy on Ubuntu, it’s important to make sure your system’s software is up to date.

🐧Bash / Shell
sudo apt update
sudo apt dist-upgrade
sudo apt autoremove

Running the commands above will update and remove obsolete packages from your system. It’s also a good idea to reboot the server after running them.

Install OpenJDK 8

Apache Groovy needs Java to run, so the next step is to install the OpenJDK 8 development kit on your Ubuntu system.

For this tutorial, we’re going to install OpenJDK.

To do that, run the commands below:

🐧Bash / Shell
sudo apt update
sudo apt-get install openjdk-8-jdk openjdk-8-doc

After installing Java, you can verify it by running the commands below:

💻Code
java -version

It should output something similar, as shown below:

💻Code
Output:
openjdk version "1.8.0_242"
OpenJDK Runtime Environment (build 1.8.0_242-8u242-b08-0ubuntu3~18.04-b08)
OpenJDK 64-Bit Server VM (build 25.242-b08, mixed mode)

With Java installed and your system updated, you’re ready to install Apache Groovy.

Download Apache Groovy

Now that Java is ready, you can download and install Apache Groovy on Ubuntu using the simple SDKMAN install script.

To do that, run the commands below:

🐧Bash / Shell
sudo apt install curl
curl -s get.sdkman.io | bash

Running that command will download any necessary supporting software (dependencies) and get your system ready for Groovy.

After a successful installation, you should get a similar message as shown below:

💻Code
Extract script archive…
Install scripts…
Set version to 5.7.4+362 …
Attempt update of interactive bash profile on regular UNIX…
Added sdkman init snippet to /home/richard/.bashrc
Attempt update of zsh profile…
Updated existing /home/richard/.zshrc
All done!
Please open a new terminal, or run the following in the existing one:
source "/home/richard/.sdkman/bin/sdkman-init.sh"
Then issue the following command:
sdk help
Enjoy!!!

After running the commands above, run the commands below to set the Groovy environment.

💻Code
source "$HOME/.sdkman/bin/sdkman-init.sh"

Finally, run the commands below to install Groovy.

💻Code
sdk install groovy

That should install Groovy and show a similar message as below after the installation:

💻Code
==== BROADCAST =================================================================
2020-04-03: Grails 4.0.3 released on SDKMAN! #grailsfw
2020-04-03: Micronaut 1.3.4 released on SDKMAN! #micronautfw
* 2020-04-02: Micronaut 2.0.0.M2 released on SDKMAN! #micronautfw
Downloading: groovy 3.0.2
In progress…
############################################################################ 100.0%
Installing: groovy 3.0.2
Done installing!
Setting groovy 3.0.2 as default.

That should do it!

After installing, you can check whether Groovy is installed by displaying its version number.

💻Code
groovy -version

It should then display a similar line as shown below:

💻Code
Groovy Version: 3.0.2 JVM: 1.8.0_242 Vendor: Private Build OS: Linux

This is how to install Apache Groovy on Ubuntu!

To launch Groovy, run the command below:

💻Code
groovysh

That should open Groovy shell.

💻Code
Apr 05, 2020 5:10:31 PM java.util.prefs.FileSystemPreferences$1 run
INFO: Created user preferences directory.
Groovy Shell (3.0.2, JVM: 1.8.0_242)
Type ':help' or ':h' for help.
groovy:000>

Conclusion:

  • Installing Apache Groovy on Ubuntu is a straightforward process that enhances your development capabilities.
  • Groovy’s syntax is easy to learn, making it accessible for both new and experienced developers.
  • By integrating Groovy with Java, developers can create more dynamic applications and scripts.
  • Using Ubuntu as your operating system allows for efficient software management and installation.
  • The process involves updating your system, installing Java, and using a simple script to install Groovy.
  • After installation, you can easily access Groovy through the command line, enabling you to start developing right away.

Was this guide helpful?

Was this helpful?
Richard

About the Author

Richard

Tech Writer, IT Professional

Richard, a writer for Geek Rewind, is a tech enthusiast who loves breaking down complex IT topics into simple, easy-to-understand ideas. With years of hands-on experience in system administration and enterprise IT operations, he’s developed a knack for offering practical tips and solutions. Richard aims to make technology more accessible and actionable. He's deeply committed to the Geek Rewind community, always ready to answer questions and engage in discussions.

0 Comments

Leave a Comment

Your email address will not be published. Required fields are marked *

Exit mobile version