How do I install Groovy?

I recovered from this error by doing :

sudo apt-get purge openjdk*

This will prompt you to remove the openjdk that have been installed in your system. Proceed with it. After the openjdk have been removed from your pc, you can do :

sudo apt-add-repository ppa:groovy-dev/groovy
sudo apt-get update
sudo apt-get install groovy

This installs the stable version. After that do this, in your terminal :

groovy -version

This should give you the output :

Groovy Version: 1.8.6 JVM: 1.6.0_24 Vendor: Sun Microsystems Inc. OS: Linux

Instead, I simply installed the GVM (Groovy enVironment Manager) and used that to install groovy.