How to Install Apache Groovy on Ubuntu Linux
Apache Groovy is a dynamic programming language that runs on the Java Virtual Machine (JVM) and helps you write and test code faster than standard Java. Installing Apache Groovy version 4.0.1 on Ubuntu 22.04 and 20.04 LTS takes just a few minutes using basic command-line tools.
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
Preparing your Ubuntu system before you install Apache Groovy Ubuntu ensures your package lists are current and removes old files that might cause conflicts. Run update and upgrade commands in your terminal to refresh your software sources and get your system ready for the installation process.
sudo apt update sudo apt dist-upgrade sudo apt autoremove
These commands refresh package lists and remove obsolete software. Reboot the system once they finish.
Install OpenJDK 8
Installing OpenJDK 8 (an open-source implementation of the Java Platform) gives your system the Java environment required to run Groovy on Ubuntu. You need this software package installed and working before you can set up Groovy itself.
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
Downloading Apache Groovy on Ubuntu relies on SDKMAN (a tool for managing Software Development Kits) to handle the setup process. You need to install curl (a command-line tool for transferring data using URLs) first so you can fetch and run the SDKMAN installation script.
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>
Wrapping up, installing Apache Groovy on Ubuntu expands your development toolkit without unnecessary hurdles.
- 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.