In this article we shall look at how to install Apache Groovy on Ubuntu 22.04|20.04|18.04|16.04. Apache Groovy is a powerful dynamic language for JVM. It has easy to learn syntax, static-typing and compilation capabilities aimed at improving developer productivity.
Groovy integrates well with any Java program to provide features such as domain-specific Language authoring, Scripting capabilities, runtime, and compile-time meta-programming and functional programming.
Follow Steps below to Install the latest Apache Groovy on Ubuntu 22.04|20.04|18.04|16.04.
Step 1: Update your system
Ensure you are running an up-to-date Ubuntu OS:
sudo apt update
sudo apt -y upgrade
sudo reboot
Step 2: Install Java and other dependencies on Ubuntu
Next we perform an installation of Java on Ubuntu Linux system
sudo apt update
sudo apt install -y default-jdk unzip zip
Confirm successful Java installation by checking the version:
$ java -version
openjdk version "11.0.13" 2021-10-19
OpenJDK Runtime Environment (build 11.0.13+8-Ubuntu-0ubuntu1.20.04)
OpenJDK 64-Bit Server VM (build 11.0.13+8-Ubuntu-0ubuntu1.20.04, mixed mode, sharing)
Step 3: Download and Run Groovy Installer Script
There are many ways of installing Groovy on Ubuntu 22.04/20.04/18.04/16.04, The easiest and quicker method involves the use of an installer script.
$ curl -s get.sdkman.io | bash
If the installation is successful you should get an output similar to one below:
-+syyyyyyys:
`/yho:` -yd.
`/yh/` +m.
.oho. hy .`
.sh/` :N` `-/o` `+dyyo:.
.yh:` `M- `-/osysoym :hs` `-+sys: hhyssssssssy+
.sh:` `N: ms/-`` yy.yh- -hy. `.N-````````+N.
`od/` `N- -/oM- ddd+` `sd: hNNm -N:
:do` .M. dMMM- `ms. /d+` `NMMs `do
.yy- :N` ```mMMM. - -hy. /MMM: yh
`+d+` `:/oo/` `-/osyh/ossssssdNMM` .sh: yMMN` /m.
-dh- :ymNMMMMy `-/shmNm-`:N/-.`` `.sN /N- `NMMy .m/
`oNs` -hysosmMMMMydmNmds+-.:ohm : sd` :MMM/ yy
.hN+ /d: -MMMmhs/-.` .MMMh .ss+- `yy` sMMN` :N.
:mN/ `N/ `o/-` :MMMo +MMMN- .` `ds mMMh do
/NN/ `N+....--:/+oooosooo+:sMMM: hMMMM: `my .m+ -MMM+ :N.
/NMo -+ooooo+/:-....`...:+hNMN. `NMMMd` .MM/ -m: oMMN. hs
-NMd` :mm -MMMm- .s/ -MMm. /m- mMMd -N.
`mMM/ .- /MMh. -dMo -MMMy od. .MMMs..---yh
+MMM. sNo`.sNMM+ :MMMM/ sh`+MMMNmNm+++-
mMMM- /--ohmMMM+ :MMMMm. `hyymmmdddo
MMMMh. ```` `-+yy/`yMMM/ :MMMMMy -sm:.``..-:-.`
dMMMMmo-.``````..-:/osyhddddho. `+shdh+. hMMM: :MmMMMM/ ./yy/` `:sys+/+sh/
.dMMMMMMmdddddmmNMMMNNNNNMMMMMs sNdo- dMMM- `-/yd/MMMMm-:sy+. :hs- /N`
`/ymNNNNNNNmmdys+/::----/dMMm: +m- mMMM+ohmo/.` sMMMMdo- .om: `sh
`.-----+/.` `.-+hh/` `od. NMMNmds/ `mmy:` +mMy `:yy.
/moyso+//+ossso:. .yy` `dy+:` .. :MMMN+---/oys:
/+m: `.-:::-` /d+ +MMMMMMMNh:`
+MN/ -yh. `+hddhy+.
/MM+ .sh:
:NMo -sh/
-NMs `/yy:
.NMy `:sh+.
`mMm` ./yds-
`dMMMmyo:-.````.-:oymNy:`
+NMMMMMMMMMMMMMMMMms:`
-+shmNMMMNmdy+:`
Now attempting installation...
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%##O=# #
Extract script archive...
Install scripts...
Set version to 5.13.1 ...
Attempt update of interactive bash profile on regular UNIX...
Added sdkman init snippet to /home/ubuntu/.bashrc
Attempt update of zsh profile...
Updated existing /home/ubuntu/.zshrc
All done!
....
Then run the following in your terminal.
source "/home/$USER/.sdkman/bin/sdkman-init.sh"
The sdkinstall
command is now available for you to install the latest stable Groovy on Ubuntu Linux.
$ sdk install groovy
==== BROADCAST =================================================================
* 2022-01-28: groovy 4.0.0 available on SDKMAN!
* 2022-01-27: micronaut 3.3.0 available on SDKMAN!
* 2022-01-27: ki 0.4.5 available on SDKMAN! https://github.com/Kotlin/kotlin-interactive-shell/releases/tag/v0.4.5
================================================================================
Downloading: groovy 4.0.0
In progress...
############################################################################################################################################################################################# 100.0%
Installing: groovy 4.0.0
Done installing!
Setting groovy 4.0.0 as default.
After installation is complete test your default version of Groovy with:
$ groovy -version
Groovy Version: 4.0.0 JVM: 11.0.13 Vendor: Ubuntu OS: Linux
You should now have Groovy installed on your Ubuntu server or Workstation. You can launch Groovy shell by running:
$ groovysh
Feb 02, 2022 1:03:52 PM java.util.prefs.FileSystemPreferences$1 run
INFO: Created user preferences directory.
Groovy Shell (4.0.0, JVM: 11.0.13)
Type ':help' or ':h' for help.
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
groovy:000>
To run a specific Groovy script type:
$ groovy SomeScript
Hope our guide was helpful in installing Apache Groovy on Ubuntu 22.04|20.04|18.04|16.0 Linux system. You can read more from the official Apache Groovy Documentation