How to Install Apache Groovy on Ubuntu 18.04 | 20.04

How to Install Apache Groovy on Ubuntu 18.04 20.04

This post shows users and new students that how to Install Apache Groovy on Ubuntu 18.04 | 20.04. If you’re going to Install Apache Groovy on Ubuntu then this post is ideal for you.

Apache Groovy is a powerful, dynamic and Java-syntax-compatible object-oriented programming (OOP) language for the Java platform. It is very useful to create programs with easy to learn syntax.

It is static as well as a dynamic language with features similar to those of Python, Ruby, and Smalltalk.

For more details about Apache Groovy, please check its official website.

Follow the below steps for starting to Install Apache Groovy on Ubuntu 18.04 | 20.04 :

Step 1: Prepare Ubuntu

First of all you need to update the server before installing packages on Ubuntu. For do that, run the below :

sudo apt update
sudo apt dist-upgrade
sudo apt autoremove

Step 2: Install OpenJDK 8

If you want to use Apache Groove properly, then first, you will need Java installed. So download the Java 8 Development Kit. you can us official Oracle JDK or OpenJDK.

Here we are going to use OpenJDK for this post, so run the below command to install install OpenJDK.

sudo apt update
sudo apt-get install openjdk-8-jdk openjdk-8-doc

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

java -version

When you run above command, it will show the result similar as 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)

Step 3: Download Apache Groovy

After installing of Java, you can download and install Groovy. To install Apache Groovy, the fastest and easiest way is to to use its install script.

For do that, simply run the below commands:

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

Above command is download all packages and prepare the server for Groovy.

After successful installation, you get a similar message similar as 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/rich/.zshrc
All done!
Please open a new terminal, or run the following in the existing one:
source "/home/rich/.sdkman/bin/sdkman-init.sh"

Then issue the following command:
sdk help

Enjoy!!!

Now run the below commands to set Groovy environment.

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

After ru above command, run the below commands to install Groovy.

sdk install groovy

The above command should install Groovy and show a message similar as below:

==== BROADCAST =================================================================
2020-09-05: Grails 4.0.3 released on SDKMAN! #grailsfw
2020-09-05: Micronaut 1.3.4 released on SDKMAN! #micronautfw
* 2020-09-04: 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.

After installing the Apache Groovy, you can check that Groovy is installed or not by run the below command:

groovy -version

The above command should show a message similar as below:

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

And finally, Run the below command to lunch Groovy :

groovysh

The above should open the Groovy shell.

Sep 05, 2020 6: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>

That’s all

If you find any error and issue in above steps , please use comment box below to report.

Related Posts

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.