Installing Grails & Intellij Idea under Ubuntu 11.10

Posted by {"display_name"=>"greg", "login"=>"greg", "email"=>"greg@udon.org", "url"=>""} on October 27, 2011 · 10 mins read

This post provides a walk-though of the steps to install Grails and Intellij Idea on ubuntu 11.10. I'm using Grails 1.3.7, Intellij Idea 10 (with Groovy & Grails support).

Ubuntu 11.10

I started with a standard Ubuntu 11.10 32 bit install. As I've written before, I'm not a big fan of the new Ubuntu Unity interface so my first step after install 11.10 is to install Gnome with the following command:

$ sudo apt-get install gnome-panel

You can then logout, select the settings icon at the login prompt and choose the Gnome Classic option.

Ubuntu App Installs

Install Java and the JDK using 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

To install mysql and phpMyAdmin, execute the command:

$ sudo apt-get install mysql-server php5-mysql phpmyadmin

To install emacs, execute the command:

$ sudo apt-get install emacs23

I use Ninite when setting up new Windows systems.  It's not as necessary for Linux but I sometimes use it to install Dropbox and Chrome.

Ubuntu Software Center App Installs

Next, I want to install Chrome and FileZilla (for ftp).  Run Applications > Ubuntu Software Center

- Edit > Reload Package Information

I then run the Applications > Ubuntu Software Center and install the following packages:

- Chromium Web Browser
- FileZilla (for ftp) 

JDK

As of this writing, the standard JDK distribution does not work with ubuntu 11.10.

With ubuntu 11.10 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

Git

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

Groovy & Grails Documentation

If you're going to use Intellij Idea 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.3.zip
$ sudo mv groovy-1.8.3 groovy

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-1.6.0.24
$ 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

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

Add $GRAILS_HOME/bin to the system wide path in the /etc/environment file, /usr/share/grails/bin on my system.

Log out and then back on again.  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

Grails MySQL & Hibernate

If you’re going to use MySQL, download the MySQL Java connector and place the file here:

MyApp/lib/mysql-connector-java-5.1.6-bin.jar

In the DataSource.groovy file, set the the following fields:

url = “jdbc:mysql://localhost/MyApp”
driverClassName = “com.mysql.jdbc.Driver”
username = “”
password = “”


Intellij Idea

Go to the Intellij Idea download page and download Idea.

$ cd $HOME
$ tar xvfz ~/Downloads/ideaIU*gz
$ cd idea-IU*/bin
$ sudo ./idea.sh

Idea will start and we will want to change some settings.

Set the preferred web browser location at File > Settings > Web Browsers

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.

SmartGIT

Go to the SmartGIT download page and download the application.

$ cd $HOME
$ tar xvfz ~/Downloads/smartgit*gz

To run SmartGIT, execute the command:

$ ~/smartgit/bin/smartgit.sh

CloudFoundry VMC

I've been using CloudFoundry as a Grails/Java PaaS provider for the past few months during their free beta period and have been very happy with the service. It's still a free service and there are resource limitations but it has worked well. The CloudFoundry VMC utility is need to push Grails updates to CloudFoundry and perform other administrative functions on your CloudFoundry instance - stop, start and check on the status of your application and its' log files.

I posted earlier on CloudFoundry but here are the commands required to install their VMC utility:

$ sudo apt­‐get install ruby­‐full
$ sudo apt-­get install rubygems
$ sudo gem install vmc
$ vmc target api.cloudfoundry.com
$ vmc login
Email: user@domain.com
Password: ********
Successfully logged into [http://api.cloudfoundry.com]

Springloops

I use springloops as a hosted source version control and offsite repository and wrote a post on configuring Git for use with springloops.

Misc Ubuntu Utilities

With Ubuntu 11.10 there are several utilities that I also like to install.

Install the Gnome Tweet Tool:

$ sudo apt-get install gnome-tweak-tool

Install the Gconf editor:

$ sudo apt-get install gconf-editor

Install the Gnome User Theme Extension:

$ sudo apt-get install gnome-tweak-toolsudo add-apt-repository ppa:webupd8team/gnome3
$ sudo apt-get update
$ sudo apt-get install gnome-shell-extensions-user-theme

The Synaptic Package Manager:

$ sudo apt-get install synaptic

Disable overlay scroll bars:

$ sudo apt-get remove overlay-scrollbar liboverlay-scrollbar3-0.2-0 liboverlay-scrollbar-0.2-0

Thanks

Thanks to the grails.org Installation post and to ganu for his ubuntu grails install post.

Also to WEB UPD8 for their Things to Tweak post for Ubuntu 11.10

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

Updates

Updates from the original posting -

Oct 28, 2011: Added mysql and phpmyadmin install step.

Oct 30, 2011: Added Grails MySQL & Hibernate section.