How to install Apache Groovy on Ubuntu

How To Install Apache Groovy On Ubuntu 20.04 LTS

On this article we will discuss how to install Apache Groovy on Ubuntu 20.04 LTS.

Introduction

If we are a Java developer who’s going to develop an applications, We hope if there are tools that can help us to speed up application development, easily integrate with other java program. Feature rich which is inspired by any languages like Python, Ruby and Smalltalk while maintaining the strength of Java. Apache Groovy can be an answer.

Apache Groovy is a Java-syntax-compatible object-oriented programming language for the Java platform. Groovy can be used as both a programming language and a scripting language for the Java Platform. Groovy as a programming language becaus it be compiled to Java virtual machine (JVM) bytecode, either as a scripting language, it can interoperate seamlessly with other Java code and libraries.

Apache Groovy 1.0 was released on January 2, 2007 and the last stable version 3.0.5, was released on July 19, 2020. We are going to use Groovy version 3.0.5 for our tutorial purpose.

Apache Groovy Installation on Ubuntu 20.04 LTS

Before starting, we must first confirm if our system environment is supports for the installation process. The installation process will consist of several stages, namely:

  • Prerequisite
  • Download Apache Groovy
  • Installation Apache Groovy
  • Trying Groovy

Prerequisite

We have to prepare Ubuntu 20.04 LTS system with good internet connection and sufficient disk space for Groovy binary file. Java (official Oracle JDK or Open JDK) and curl installed on our system. Please verify, the Java and curl was installed by submitting command line :

ramans@otodiginet:~$ java --version
openjdk 11.0.8 2020-07-14
OpenJDK Runtime Environment (build 11.0.8+10-post-Ubuntu-0ubuntu120.04)
OpenJDK 64-Bit Server VM (build 11.0.8+10-post-Ubuntu-0ubuntu120.04, mixed mode, sharing)
ramans@otodiginet:~$ curl --version
curl 7.68.0 (x86_64-pc-linux-gnu) libcurl/7.68.0 OpenSSL/1.1.1f zlib/1.2.11 brotli/1.0.7 libidn2/2.2.0 libpsl/0.21.0 (+libidn2/2.2.0) libssh/0.9.3/openssl/zlib nghttp2/1.40.0 librtmp/2.3
Release-Date: 2020-01-08
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtmp rtsp scp sftp smb smbs smtp smtps telnet tftp
Features: AsynchDNS brotli GSS-API HTTP2 HTTPS-proxy IDN IPv6 Kerberos Largefile libz NTLM NTLM_WB PSL SPNEGO SSL TLS-SRP UnixSockets
Apache Groovy install
Checking Java and curl version

If your system is still doesn’t have Java installed, just install Java and curl first, because Apache Groovy need Java as its platform. We could found an articles related to Java installation on https://otodiginet.com/software/how-to-install-java-openjdk-11-on-centos-8/ for Open JDK installation or https://otodiginet.com/software/how-to-install-oracle-java-12-in-linux-ubuntu-18-04/ for Oracle Java installation.

Download Apache Groovy

The quickest and easiest way is to install Apache Groovy is by using its install script, the script should download all dependencies and prepare the server for Groovy. For this purpose we have to submit command line below :

ramans@otodiginet:~$ curl -s get.sdkman.io | bash
Groovy Installation Script

The output will be :

Looking for a previous installation of SDKMAN…
Looking for unzip…
Looking for zip…
Looking for curl…
Looking for sed…
Installing SDKMAN scripts…
Create distribution directories…
Getting available candidates…
Prime the config file…
Download script archive…
################################################################## 100.0%
Extract script archive…
Install scripts…
Set version to 5.9.0+555 …
Attempt update of interactive bash profile on regular UNIX…
Added sdkman init snippet to /home/ramans/.bashrc
Attempt update of zsh profile…
Updated existing /home/ramans/.zshrc
All done!
Please open a new terminal, or run the following in the existing one:
source "/home/ramans/.sdkman/bin/sdkman-init.sh"
Then issue the following command:
sdk help
Enjoy!!!

Installation Apache Groovy

After adding installation script was done, then we will install the Groovy. For this purpose, we submit the command line below.

ramans@otodiginet:~$ sdk install groovy

The output will be :

==== BROADCAST =================================================================
2020-09-11: Micronaut 2.0.2 released on SDKMAN! #micronautfw
2020-09-11: Gradle 6.7-rc-1 released on SDKMAN! #gradle
* 2020-09-11: jbang 0.45.0 @jbangdev https://git.io/JUWYs
Downloading: groovy 3.0.5
In progress…
############################################################################################## 100.0%
Installing: groovy 3.0.5
Done installing!
Setting groovy 3.0.5 as default.
Install apache groovy on Ubuntu 20.04 LTS

The Groovy installation seems was successfully done. We can verify the installation by querying the version of Groovy. For this purpose just submit command line below :

ramans@otodiginet:~$ groovy -version
Groovy Version: 3.0.5 JVM: 11.0.8 Vendor: Ubuntu OS: Linux
Groovy version 3.0.5

Trying Apache Groovy

So far, the Groovy installation was successfully done, the we are going to try the Groovy by entering its console. For this purpose, we will submit the command line blow to call the Groovy console. The Groovy console can be called by texting ‘groovysh‘.

ramans@otodiginet:~$ groovysh
Groovy Shell (3.0.5, JVM: 11.0.8)
Type ':help' or ':h' for help.
---------------------------------------------------------------------------------------------------------------------------------------------------------
groovy:000> :help
For information about Groovy, visit:
http://groovy-lang.org
Available commands:
:help (:h ) Display this help message
? (:? ) Alias to: :help
:exit (:x ) Exit the shell
:quit (:q ) Alias to: :exit
import (:i ) Import a class into the namespace
:display (:d ) Display the current buffer
:clear (:c ) Clear the buffer and reset the prompt counter
:show (:S ) Show variables, classes or imports
:inspect (:n ) Inspect a variable or the last result with the GUI object browser
:purge (:p ) Purge variables, classes, imports or preferences
:edit (:e ) Edit the current buffer
:load (:l ) Load a file or URL into the buffer
. (:. ) Alias to: :load
:save (:s ) Save the current buffer to a file
:record (:r ) Record the current session to a file
:history (:H ) Display, manage and recall edit-line history
:alias (:a ) Create an alias
:set (:= ) Set (or list) preferences
:grab (:g ) Add a dependency to the shell environment
:register (:rc) Register a new command with the shell
:doc (:D ) Open a browser window displaying the doc for the argument
Trying apache Groovy

Conclusion

Apache Groovy installation on Ubuntu 20.04 LTS has been done successfully, just drop your comment on the ‘comment area’ below. Have a nice day !

Share this article via :

Leave a Reply

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