How to Install Apache Groovy on Ubuntu Linux

Computer screen with app icons
Computer screen with app icons

This tutorial instructs users on installing Apache Groovy on Ubuntu 20.04 or 18.04. Apache Groovy is a dynamic language for the Java platform that aids developers in building programs with simple syntax. The guide details the process of updating the server, installing OpenJDK 8, downloading and installing Groovy through an install script, and enabling the Groovy environment.

This brief tutorial shows students and new users how to install Apache Groovy on Ubuntu 20.04 | 18.04.

For the uninitiated, Apache Groovy is a powerful, dynamic language for the Java platform that helps developers create programs with easy-to-learn syntax.

It is a great tool that integrates smoothly with any Java program, enabling developers to create better applications with powerful features, including scripting capabilities.

If you’re a Java developer who will be developing applications, integrating Apache Groovy with your codes should be something you might want to do.

For more about Apache2 Groovy, please check its homepage.

To get started with installing Apache Groovy on Ubuntu, follow the steps below:

Prepare Ubuntu

Before installing packages on Ubuntu, you must first update the server. To do that, run the commands below:

sudo apt update
sudo apt dist-upgrade
sudo apt autoremove

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

Install OpenJDK 8

To properly use Apache Groove, you will need Java installed. First, download the Java 8 Development Kit: either the official Oracle JDK or Open JDK

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

To do that, run the commands below:

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)

Now that you have updated and installed Java continue below to install Apache Groovy.

Download Apache Groovy

Now that Java is installed, you can go and download and install Groovy. There are many ways to get Groovy installed on Ubuntu. However, the quickest and easiest way is to use its install script.

To do that, run the commands below:

sudo apt install curl
curl -s get.sdkman.io | bash

When you run the command above, it should download all dependencies and prepare the server 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 help
Enjoy!!!

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

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

Finally, run the commands below to install Groovy.

sdk install groovy

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

==== 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.

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 lunch 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:

This post showed you how to install Apache Groovy on Ubuntu 20.04 | 18.04. If you find any error, please report it in the comment form below.

Thanks,

You may also like the post below:

Posted by
Richard

I love computers; maybe way too much. What I learned I try to share at geekrewind.com.

1 Comment

  1. thnk you sir for the post.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: