---
title: "How to Install Groovy on Linux and Windows [Step-by-Step]"
description: "Learn the ins-and-outs of how to install Groovy on both Linux and Windows systems in this step-by-step tutorial by ATA Learning!"
canonical: "https://adamtheautomator.com/install-groovy/"
---

# How to Install Groovy on Linux and Windows [Step-by-Step]

> Learn the ins-and-outs of how to install Groovy on both Linux and Windows systems in this step-by-step tutorial by ATA Learning!

Source: https://adamtheautomator.com/install-groovy/

---

ATA Learning

Tap to hide

[

ATA Learning

](/)

*   [Home](/)
*   [Tutorials](/tutorials/)
*   [Instructors](/author/)
*   [Advertising](/advertising/)
*   [Recommended Resources](/resources/)
*   [About Adam](/about-adam/)

Search for:  

*   [](https://twitter.com/adbertram)
*   [](https://github.com/Adam-the-Automator)
*   [](https://www.linkedin.com/company/adam-the-automator-llc)
*   [](/feed/)

![How to Install Groovy on Linux and Windows \[Step-by-Step\]](https://adamtheautomator.com/wp-content/uploads/2022/10/How-to-Install-Groovy-on-Linux-and-Windows-Step-by-Step.jpg)

# How to Install Groovy on Linux and Windows \[Step-by-Step\]

[![](https://secure.gravatar.com/avatar/2beb65fca997135120ed98dc6a2e57dcdf1a7d7d2f5ff687b5d91dc7ccd7a6b5?s=192&d=mm&r=g)Sagar](https://adamtheautomator.com/author/shanky-mendiratta/)26 October 20224 min. read

Categories: [IT Ops](/category/it-ops/)

Tags:[Java](/tag/java/)

Table of Contents

*   [Prerequisites](#prerequisites)
*   [Installing Groovy on Ubuntu](#installing-groovy-on-ubuntu)
*   [Executing a Groovy Script on Ubuntu](#executing-a-groovy-script-on-ubuntu)
*   [Installing Groovy on Windows](#installing-groovy-on-windows)
*   [Running a Groovy Command on Windows](#running-a-groovy-command-on-windows)
*   [Conclusion](#conclusion)

As a developer, you typically look for ways to enhance application features. If you mainly work on Java-based applications, befriend and install Groovy on your machine. The Groovy language integrates smoothly with any Java program and adds powerful features, including scripting capabilities for Java programs.

And in this tutorial, you’ll learn how to install Groovy, regardless if you’re on an Ubuntu or Windows machine.

Ready? Jump in and get started with Groovy for better application development!

## Prerequisites

This tutorial contains step-by-step demonstrations. To follow along, be sure you have the following:

*   An Ubuntu machine – This tutorial uses [Ubuntu 22.04](https://releases.ubuntu.com/18.04/).

Related:[How to Install Ubuntu 20.04 \[Step-by-Step\]](https://adamtheautomator.com/install-ubuntu/)

*   A Windows 7 or 7+ machine with Java installed.

## Installing Groovy on Ubuntu

Before you install Groovy on your Ubuntu machine, you first need to install Java since Groovy runs on its built-in Java servlet container server. You can use multiple Java implementations to work with Groovy, but [OpenJDK](https://openjdk.java.net/) is the most popular.

To install Java on your Ubuntu machine:

1\. Log in to your Ubuntu machine using your favorite SSH client.

2\. Next, run the [apt update](https://linux.die.net/man/8/apt-get) command below to update your system packages.

```bash
sudo apt update
```

![Updating system packages](https://adamtheautomator.com/wp-content/uploads/2022/10/image-529.png)

Updating system packages

3\. Once updated, run the following commands to create a directory (mkdir) named _~/install\_groovy\_demo_ and switch (cd) to that directory.

These commands don’t provide output, but the _~/install\_groovy\_demo_ directory is where you’ll install Java.

```bash
mkdir ~/install_groovy_demo
cd ~/install_groovy_demo
```

4\. Now, run the [apt install](https://manpages.ubuntu.com/manpages/xenial/man8/apt.8.html) command below to install Java (default-jdk) on your machine.

```bash
# Installing Java Version: Java SE 11 (LTS)
sudo apt install default-jdk 
```

![Installing Java Version: Java SE 11 (LTS)](https://adamtheautomator.com/wp-content/uploads/2022/10/image-530.png)

Installing Java Version: Java SE 11 (LTS)

5\. After installing Java, run the below java command to check the -version of installed Java on your machine.

```bash
# Checking the Version of Java to verify Java installation.
java -version
```

The output below ensures you’ve successfully installed Java.

![Verifying Java installation](https://adamtheautomator.com/wp-content/uploads/2022/10/image-531.png)

Verifying Java installation

6\. Next, run the below curl command to download the Groovy package (get.sdkman.io).

```javascript
curl -s get.sdkman.io | bash
```

If the download is successful, you’ll see an output similar to the one below.

![Downloading the Groovy package](https://adamtheautomator.com/wp-content/uploads/2022/10/image-532.png)

Downloading the Groovy package

7\. Once downloaded, run each command below on the bin directory of the Groovy installation folder (_~/.sdkman/bin/_) to prepare Groovy scripts (_sdksdkman-init.sh_) to run successfully.

Note that these commands don’t provide output, but you’ll see the outcome in the following step.

```javascript
cd ~/.sdkman/bin/
source sdksdkman-init.sh
```

8\. Now, run the [sdk install](https://sdkman.io/usage) command below to install Groovy.

```javascript
sdk install groovy
```

![Installing the Groovy on the Ubuntu machine](https://adamtheautomator.com/wp-content/uploads/2022/10/image-533.png)

Installing the Groovy on the Ubuntu machine

9\. Finally, run the below groovy command to verify your Groovy installation.

```powershell
groovy -version
```

![Verifying the Groovy installation](https://adamtheautomator.com/wp-content/uploads/2022/10/image-534.png)

Verifying the Groovy installation

## Executing a Groovy Script on Ubuntu

Great! You’ve successfully installed Groovy on your Ubuntu machine. But how do you know Groovy actually works? In this example, you’ll run a test by executing a simple script to verify if Groovy is appropriately installed.

Within the _~/install\_groovy\_demo_ directory, create a script named [_test.sh_](http://test.sh) and populate the below line, which prints (`printLn`) all the numbers starting from `0` to `4`.

```javascript
0.upto(4) {println "$it"}
```

Now, run the below `groovy` command to execute the Groovy script (`*test.sh*`)

```javascript
groovy test.sh
```

![Running a Groovy script on Ubuntu](https://adamtheautomator.com/wp-content/uploads/2022/10/image-535.png)

Running a Groovy script on Ubuntu

## Installing Groovy on Windows

Do you mainly work on a Windows machine? Worry not. Groovy works on Windows too! But like in Ubuntu, you first have to install Groovy on your Windows machine.

1\. Open your favorite web browser, navigate [Groovy’s official download page](https://groovy.apache.org/), and click the Download tab, as shown below.

![Accessing Groovy’s official download page](https://adamtheautomator.com/wp-content/uploads/2022/10/image-536.png)

Accessing Groovy’s official download page

2\. Next, scroll down to the latest stable release, Groovy 4.0, at this time of writing, and click on Windows Installer (community artifact).

Your browser redirects to a page where you can get the download link for the Windows installer (step three).

![Accessing Groovy’s Windows installer’s download link](https://adamtheautomator.com/wp-content/uploads/2022/10/image-537.png)

Accessing Groovy’s Windows installer’s download link

3\. Click on the _.msi_ installer’s link (rightmost) to download Groovy.

![Downloading Groovy’s Windows installer](https://adamtheautomator.com/wp-content/uploads/2022/10/image-538.png)

Downloading Groovy’s Windows installer

4\. Once downloaded, run Groovy’s Windows installer.

![Launching Groovy’s Windows  installer](https://adamtheautomator.com/wp-content/uploads/2022/10/image-539.png)

Launching Groovy’s Windows installer

5\. Now, click Next when you see the “welcome” page below.

![Acknowledging the “welcome” page](https://adamtheautomator.com/wp-content/uploads/2022/10/image-540.png)

Acknowledging the “welcome” page

6\. Tick the checkbox at the bottom to accept the End-User License Agreement (EULA), and click Next to continue.

![Accepting the End user License Agreement](https://adamtheautomator.com/wp-content/uploads/2022/10/image-541.png)

Accepting the End user License Agreement

7\. Further, select the Groovy setup as Typical, which installs only the common features.

![Selecting the Typical Groovy setup](https://adamtheautomator.com/wp-content/uploads/2022/10/image-542.png)

Selecting the Typical Groovy setup

As shown below, the installation begins and may take a few minutes to complete.

![Installing Groovy on a Windows machine](https://adamtheautomator.com/wp-content/uploads/2022/10/image-543.png)

Installing Groovy on a Windows machine

8\. Lastly, click on Finish once Groovy has been installed successfully. And at this point, the command line tools Groovy shell and Groovy console are installed by default.

![Successfully Installed groovy on the Windows machine](https://adamtheautomator.com/wp-content/uploads/2022/10/image-544.png)

Successfully Installed groovy on the Windows machine

## Running a Groovy Command on Windows

You now have Groovy installed on your Windows machine, which should work as expected. But to be safe, you’ll have to test if Groovy works correctly. How?

Similar to what you did in Ubuntu, you’ll run a Groovy command on your Windows machine. But instead of Windows PowerShell, you’ll use the Groovy Shell to run commands.

Related:[What is PowerShell and Why Use It?](https://adamtheautomator.com/what-is-powershell/)

Launch Groovy shell from your Desktop or the Start menu, as shown below.

![Launching the Groovy Shell on the Windows machine](https://adamtheautomator.com/wp-content/uploads/2022/10/image-545.png)

Launching the Groovy Shell on the Windows machine

Now, run the below command to print all numbers (`printLn`) between `0` and `7` with an increment of `2`.

```javascript
0.step(7,2){println "$it"}
```

![Executing a Groovy command to print specific numbers](https://adamtheautomator.com/wp-content/uploads/2022/10/image-546.png)

Executing a Groovy command to print specific numbers

## Conclusion

In this tutorial, you learned how to install Groovy, a multi-faceted language for the Java platform, on Ubuntu and Windows. You touched on executing a Groovy script and running a Groovy command with similar functions.

After realizing how Groovy works, why not automate web deployments using Groovy and [create a Jenkins CI CD pipeline](https://adamtheautomator.com/jenkins-ci-cd/)? Drastically improve your software development process today!

Related:[Create a Jenkins Build Job to Automate Web Deployments](https://adamtheautomator.com/jenkins-build-job/)

Share this article

[Share on X](https://twitter.com/intent/tweet?url=https%3A%2F%2Fadamtheautomator.com%2Finstall-groovy%2F&text=How%20to%20Install%20Groovy%20on%20Linux%20and%20Windows%20%5BStep-by-Step%5D)[Share on Facebook](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fadamtheautomator.com%2Finstall-groovy%2F)[Share on LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fadamtheautomator.com%2Finstall-groovy%2F)

## Related Posts

![](https://adamtheautomator.com/wp-content/uploads/2023/08/java-on-raspberry-pi.jpg)

### [Learn How to Install Java on Raspberry Pi](/java-on-raspberry-pi/)

Learn how to install and get started with the ins and outs of Java on Raspberry Pi in this ATA Learning tutorial!

![](https://adamtheautomator.com/wp-content/uploads/2022/11/install-java-on-mac.jpg)

### [How to Install Java on Mac](/install-java-on-mac/)

Learn how to install Java on Mac securely and safely with either OpenJDK or Oracle Java to run all of your Java applications!

![](https://adamtheautomator.com/wp-content/uploads/2019/06/5d238ae5c824b514689ea597.jpg)

### [Active Directory Health Check: PowerShell Scripting](/removing-old-java/)

Monitor the health of your Active Directory with our comprehensive PowerShell script. A must-have for IT admins.

## Categories

*   [IT Ops](/category/it-ops/)
*   [Cloud](/category/cloud/)
*   [DevOps](/category/devops/)
*   [Home Ops](/category/home-ops/)
*   [Information Security](/category/infosec/)
*   [Software Development](/category/software-development/)

## Site

*   [Home](/)
*   [Tutorials](/tutorials/)
*   [Instructors](/author/)
*   [Advertising](/advertising/)
*   [Recommended Resources](/resources/)
*   [About Adam](/about-adam/)

Copyright 2026© ATA Learning | [Privacy Policy](/privacy/)
