Category Archives: OSX

Mac OS X

Installing Groovy on OS X 10.6

Groovy is an agile, dynamic language for the Java platform. It has the speed and flexibility of Ruby but it compiles down to Java bytecode. It’s the foundation of the Grails framework.

Here’s how to install Groovy 1.7.9 on Mac OS X 10.6 Snow Leopard.  It should also work on earlier versions of Groovy and OS X. I will note that Groovy does provide instructions, but I prefer these. There’s also a MacPorts installer, but I never have any luck with MacPorts.

Install Java SDK

Before you install Groovy, make sure you have a Java SDK 1.5+ installed.  The Java runtime that comes preinstalled with OS X does not have the SDK.

Download Groovy

Download Groovy from groovy.codehaus.org.

Install Groovy

Unpack the archive you downloaded.  It’ll be a folder.

Move the folder to /usr/share/java. I just used Finder, but here’s the obligatory Terminal command:

$ sudo mv ~/downloads/groovy-1.7.9/usr/share/java

Create a symlink that allows you to access Groovy without referencing the version number.  This way, to upgrade your Groovy you just install the newer version alongside the old one, and update this symlink.  This is a standard best practice.

$sudo ln -s groovy-1.7.9 groovy

To make Groovy available, add the following either to /etc/profile (for everyone) or ~/.profile (for just you):

export GROOVY_HOME=/usr/share/java/groovy
export PATH=$GROOVY_HOME/bin:$PATH

If you haven’t set the JAVA_HOME environment variable yet, create one in .profile that points to the path where Java’s installed. It’ll be something like this.

export JAVA_HOME=/Library/Java/Home

Let’s see if it works. Open Terminal and type:

$groovy

You should see:

Groovy Shell (1.7.9, JVM: 1.6.0_24)
Type 'help' or '\h' for help.
------------------------------------------------------------
groovy:000>

This is Groovy’s interactive command shell. Hit Ctrl-C to exit.

Now go get yer Groov on!

Installing Grails on OS X 10.6

Grails is an excellent rapid application development framework that integrates well with many industrial-strength analytics products.

Here’s how to install Grails 1.3.7 on Mac OS X 10.6 Snow Leopard.  It should also work on earlier versions of Grails and OS X. I will note that Grails.org does provide instructions, but I prefer these.

Install Java SDK

Before you install Grails, make sure you have a Java SDK 1.5+ installed.  The Java runtime that comes preinstalled with OS X does not have the SDK.

Download Grails

Download Grails from grails.org.

Install Grails

Unpack the archive you downloaded.  It’ll be a folder.

Move the folder to /usr/share/java. I just used Finder, but here’s the obligatory Terminal command:

$ sudo mv ~/downloads/grails-1.3.7/usr/share/java

Note:  some people install it to /usr/share/, but these instructions install it to /usr/share/java because that’s where other Java tools like Maven, Ant, JUnit and Derby are installed. Grails’ official instructions suggest your home directory (~/grails), which is just plain weird.

Change ownership and permissions:

$cd /usr/share/java
$sudo chown -R root:wheel grails-1.3.7/
$sudo chmod 0755 grails-1.3.7/bin/*

Create a symlink that allows you to access Grails without referencing the version number.  This way, to upgrade your Grails you just install the newer version alongside the old one, and update this symlink.  This is a standard best practice.

$sudo ln -s grails-1.3.7 grails

To make Grails available, add the following either to /etc/profile (for everyone) or ~/.profile (for just you):

export GRAILS_HOME=/usr/share/java/grails
export PATH=$GRAILS_HOME/bin:$PATH

If you haven’t set the JAVA_HOME environment variable yet, create one in .profile that points to the path where you have installed Java. It’ll be something like this.

export JAVA_HOME=/Library/Java/Home

Let’s see if it works. Open Terminal and type:

$grails

You should see:

Welcome to Grails 1.3.7 - http://grails.org/
Licensed under Apache Standard License 2.0
Grails home is set to: /usr/share/java/grails
No script name specified. Use 'grails help' for more info or 'grails interactive' to enter interactive mode

Happy Grailing!

Parallels: browser test your OS X localhost

As a developer, you’ll have to pry my Macbook out of my cold, dead fingers.  But most of the world lives and breathes Windows, so I test my web application on Microsoft Internet Explorer and Firefox for Windows.

The easiest way to do this is to run Parallels.  I’ve got Parallels virtual machines for XP, Vista and Windows 7.   I’ve got different virtual machines for XP with IE 6, 7 and 8 .  I even browser test on Ubuntu (god knows why).

But, how do all those Windows browsers access the web server running on your OSX localhost?  Localhost on the PC maps to its own localhost, not the host Mac.

Take your pick:

http://<yourcomputer>.local:  OS X creates a DNS entry on the local network named <yourcomputer>.local.   You find your computer’s name in Control Panel > Sharing.   I named my computer MoBook, so in Internet Explorer I type http://mobook.local/ to hit the webserver I have running on OS X at http://localhost:80/

http://yourgatewayIPaddress: Parallels creates a little DHCP network for your virtual machines, and the OS X machine itself is at the gateway IP.   Go into Parallels > Preferences > Advanced > Network and the gateway is most likely the Start Address with a 0, 1 or 2 in front of it.  For example, my Start Address is 10.211.55.1 and in Internet Explorer I type http://10.211.55.2 to hit the webserver I have running on OS X at http://localhost:80.

This is with Parallels 6.  These should also work in previous versions of Parallels, as well as VMWare Fusion.