8 May 2011

Installing Grails & NetBeans on ubuntu 11.04

This post provides a walk-though of the steps to install Grails and NetBeans on ubuntu 11.04. I'm using Grails 1.3.7, NetBeans 7.0 Java SE Edition (with Groovy & Grails support).


Git is not required for this configuration but I've become a fan of git for version control and you can find a good description of using git with Grails here.

$ sudo apt-get install git-core
$ git config --global user.name "YOUR NAME"
$ git config --global user.email "YOUR EMAIL"
$ git config --list


As of this writing, the standard JDK distribution does not work with ubuntu 11.04 but you'll find those instructions here.

With ubuntu 11.04 I had to execute these commands:

$ sudo add-apt-repository ppa:ferramroberto/java
$ sudo apt-get update
$ sudo apt-get install sun-java6-jre sun-java6-bin sun-java6-jdk

Set the JAVA_HOME environment variables in /etc/profile and your .bashrc file. Use the first two dpkg commands shown here if you want to confirm the JVM install location for your system.

$ dpkg --get-selections sun*
$ dpkg -L sun-java6-bin | grep bin/java
$ JAVA_HOME=/usr/lib/jvm/java-6-sun-
$ export JAVA_HOME

Groovy & Grails Documentation

If you're going to use NetBeans or another IDE, you'll want it to reference the Groovy documentation.

Download the Groovy & Grails documentation and unzip in /usr/share/doc.

- Download the Groovy 1.8 documentation to your download directory.
- Download the Grails 1.3.7 documentation.

Open a terminal session and enter the following commands:

$ sudo mkdir /usr/share/doc/grails
$ cd /usr/share/doc/grails
$ sudo unzip ~/Downloads/grails-docs-1.3.7.zip
$ cd /usr/share/doc
$ sudo unzip ~/Downloads/groovy-docs-1.8.0.zip
$ sudo mv groovy-1.8.0 groovy


Optionally, install Groovy.

$ sudo apt-get install groovy

Grails - Package Manager Install

As of this writing, I have not been able to complete the package manager based install because of failures in the gradlew build steps. Instead, I've been using the pre-built package install described in the next section.

Install grails using the ubuntu package manager:

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

Use the dpkg command to confirm the directory where grails

$ dpkg --get-selections sun*
$ dpkg -L sun-java6-bin | grep bin/java
$ JAVA_HOME=/usr/lib/jvm/java-6-sun-
$ export JAVA_HOME
$ cd /usr/share/grails/grails-1.3.7
$ ./gradlew libs
$ ./gradlew install

The gradlew libs command failed with an error associated with accessing the cache. After numerous attempts to address this issue, I gave up on the package manager based install of grails and am switching to the download install.

Grails - Pre-built Package Install

Download Grails 1.3.7 to your Downloads directory.

$ cd /usr/share
$ sudo unzip ~/Downloads/grails-1.3.7.zip
$ sudo mv grails-1.3.7 grails

Set the GRAILS_HOME environment variable in /etc/profile and add $GRAILS_HOME/bin to the system wide path in the /etc/environment file.


Add the grails executable directory, /usr/share/grails/bin on my system, to your path in the /etc/environment file.

Test your install by entering the grails command and you should see results similar to this.

$ grails
Welcome to Grails 1.3.7 - http://grails.org/
Licensed under Apache Standard License 2.0
Grails home is set to: /usr/share/grails/grails-1.3.7

To complete the test of your install try this:

$ grails create-app test
$ cd test
$ grails run-app
Running Grails application..
Server running. Browse to http://localhost:8080/test


Go to the NetBeans download page and download the Java SE edition. We'll add Grails support later to save disk space and for better runtime performance.

$ cd Downloads
$ chmod +x netbeans-7.0-ml-javase-linux.sh
$ ./netbeans-7.0-ml-javase-linux.sh

Add the netbeans bin directory to your path and then run netbeans.

$ PATH=$PATH:~/netbeans-7.0/bin
$ netbeans

From the main screen, click on the My NetBeans tab and then select the Install Plugins option. Scroll through the list of plugins and choose the Groovy and Grails and Git plugins. Click Install and follow the prompts.

After re-starting NetBeans, select Tools > Options > Groovy and enter the Groovy Doc directory (/usr/share/doc/groovy/html on my system) and click Ok. Select File > New Project, then select Groovy > Grails Application. Pick next and enter name for your project. For the Project Location, I create a directory in my Dropbox folder.


Thanks to Dean Del Ponte for his blog on grails: getting started in netbeans 6.7 and to the grails.org Installation post and to ganu for his ubuntu grails install post.

As a newbie to the ubuntu/Debian package manager, thanks to Matthew Danish for his APT and DPKG Quick Reference.

To list all installed packages: dpkg --get-selections
To list the files that are in a specific package: dpkg -L To list info about a specific package: dpkg -s

Using Git with Grails - http://www.grails.org/plugin/git