How to Install Apache Groovy on Ubuntu Linux
Apache Groovy on Ubuntu Linux lets you add a flexible programming language to your system that works well with Java.
Apache Groovy is a dynamic, object-oriented language designed for the Java Virtual Machine (JVM). It offers a simpler way to write code compared to Java.
This tutorial shows you how to install Groovy, specifically version 4.0.1, on Ubuntu 22.04 and 20.04 LTS. You’ll use the system’s built-in tools to get it set up.
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
Prepare Ubuntu: The first step to install Apache Groovy is preparing your Ubuntu system. Updating your software ensures you have the latest versions and cleans out old files, making your system ready for new installations. After running the update commands, it’s a good idea to restart your computer.
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
You need to install OpenJDK 8 on your Ubuntu system because Apache Groovy requires Java (the programming environment) to run. This command installs the necessary Java tools that Groovy depends on. After installation, you can check if Java is set up correctly by typing ‘java -version’ in your terminal.
For this tutorial, we’re going to install OpenJDK.
Run the following commands:
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:
java -version
It should output something similar, as shown below:
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
Apache Groovy installation on Ubuntu requires SDKMAN (a tool for managing Software Development Kits). First, install the `curl` command-line tool if you do not have it. (`curl` is a tool for transferring data with URLs). Then, run the SDKMAN install script; this script downloads supporting software and prepares your Ubuntu system to install Groovy.
Run the following commands:
sudo apt install curl curl -s get.sdkman.io | bash
This command downloads any necessary supporting software (dependencies) and prepares your system for Groovy.
After a successful installation, you should get a similar message as shown below:
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 helpEnjoy!!!
After running the previous commands, execute these to set the Groovy environment:
source "$HOME/.sdkman/bin/sdkman-init.sh"
Finally, run these commands to install Groovy.
sdk install groovy
This installs Groovy and should display a similar message afterwards:
==== 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 completes the installation.
After installation, check Groovy’s version number.
groovy -version
It should then display a similar line as shown below:
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:
groovysh
That should open Groovy shell.
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?
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.
thnk you sir for the post.