Tuesday, May 19, 2015


Groovy Installation

$ curl -s get.gvmtool.net | bash

$ source "/Users/uki/.gvm/bin/gvm-init.sh"

$ gvm install groovy

$ groovy -version

Groovy Version: 2.4.3 JVM: 1.7.0_79 Vendor: Oracle Corporation OS: Mac OS X

$ which groovy


To add Groovy permanently to your Terminal  PATH

edit ~/.bash_profile
# Groovy updated May 19, 2015
export GROOVY_HOME=/Users/uki/.gvm/groovy/current
export PATH=${PATH}:${GROOVY_HOME}/bin

First Script

groovy_scripts $ cat hello.groovy 

println 'Hello from Groovy'
groovy_scripts $ groovy hello

Hello from Groovy

Groovy Console

Groovy Console is good for quick testing of Scripts, especially copy and paste from the Web.

$ groovyConsole

interface Alive{
   void alive()

class Creature implements Alive{
    def grawl() {
        println(" Grrrrrrrr!!! grawls the Creature")
    void alive()
        println(" Grrrrr!!! thinks the Creature")

class Human extends Creature {
    String name;
    def sayHi(name) {
        println(" Hi, my name is $name! says the Human")
    void alive()
        println(" I am alive! says the Human")

Creature me = new Human()
me.name = "Uki"
me.sayHi me.name

Creature bear = new Creature();


uki@ groovy_scripts $ groovy hello
 Grrrrrrrr!!! grawls the Creature
 I am alive! says the Human
 Hi, my name is Uki! says the Human

 Grrrrr!!! thinks the Creature

If you like this post, please give me your 2 cents ($0.02 litterally) to show token of appreciation and encourage me to write more:

Donate Bitcoins