How to install Java and Groovy in Oracle Always free Ubuntu

Refer to following URL to install Java and Groovy in Ubuntu

https://computingforgeeks.com/how-to-install-apache-groovy-on-ubuntu-18-04-ubuntu-16-04/

How to Install Java on Ubuntu

http://groovy-lang.org/install.html
Install Java to Ubuntu
You need to upgrate your Ubuntu to the latest version
sudo apt update
sudo apt -y upgrade
sudo reboot
sudo apt-get install default-jdk
The jdk will be installed at /usr/lib/jvm

After this, we need to setup the JAVA_HOME environment parameter
go to folder /etc

change the “environment” file and add a new line of the JAVA_HOME
you need to use sudo vi environment to open the file and edit, since this folder needs root access

JAVA_HOME=/usr/lib/jvm/default-java

after saving the file, use to load the new profile and double check the setting
source environment
echo $JAVA_HOME

Install Groovy
before installing Groovy, we need to install zip and unzip tool
sudo apt-get install -y zip
sudo apt-get install -y unzip

and after this, we refer to following Groovy official document to install Groovy
http://groovy-lang.org/install.html

We need to use sudo to install the sdkman
sudo curl -s get.sdkman.io | sudo bash

we need to change user to root to execute the sdkman-init.sh
sudo -s
source “$HOME/.sdkman/bin/sdkman-init.sh”

now install groovy using root account
sudo -s
sdk install groovy
groovy -version

 

The groovy was installed under following directory
/home/ubuntu/.sdkman/candidates/groovy/current/bin

 

need to add the same to environment so it will take in the setting in PATH
/etc/environment

now we can try to deploy the groovy script in the ubuntu server and try to run them