How to install Groovy on OS X

Setup Groovy with OS X 10.9.2 Mavericks using brew.

brew install groovy
echo "export GROOVY_HOME=/usr/local/opt/groovy/libexec" | tee -a ~/.bash_profile; source ~/.bash_profile

Here is a little test script taken from Groovy’s quickstart guide.

//hello.groovy
println "hello, world"
for (arg in this.args ) {
    println "Argument:" + arg;
}
// this is a comment
/* a block comment, commenting out an alternative to above:
this.args.each{ arg -> println "hello, ${arg}"}
*/

Save that has hello.groovy and run it with the following command:

groovy hello.groovy MyName yourName HisName

You should have the following apps installed:

  • groovy
  • groovyConsole
  • groovyc
  • groovydoc
  • groovysh
Apr 15, 2014 Programming