Java Developer

How to setup your linux machine for grails development

Since this is my first post, I want to start with something very simple yet useful. Usually, our first hurdle when studying a technology or framework is to setup our development environment. Assuming your machine is Linux based, this is how to prepare your machine. For this guide, my operating system is Linux Mint 14 Cinnamon, which is based on Ubuntu 12.10

First install JDK. As of grails 2.2, it is recommended to use Java 6 instead of Java 7. Otherwise you will run into some problems when using this particular version of Grails.

sudo apt-get install openjdk-6-jdk

Next is to install Grails by downloading it on their site and not through aptitude. Note that I like downloading all Java related software to my $HOME/java folder.
$ pwd
/home/javaguy
$ mkdir java
$ cd java
$ pwd
/home/javaguy/java
$ wget http://dist.springframework.org.s3.amazonaws.com/release/GRAILS/grails-2.2.2.zip
$ unzip grails-2.2.2.zip
The grails software is now in /home/javaguy/java/grails-2.2.2 directory
Now we setup the environment variables. Note that I assume you are using bash as your shell. Edit /etc/bash.bashrc and append the following at the bottom.
export GRAILS_HOME=/home/javaguy/java/grails-2.2.2
export JAVA_HOME=/usr/lib/jvm/java-6-openjdk-amd64
export PATH=$PATH:$JAVA_HOME/bin:$GRAILS_HOME/bin
Please check your proper JAVA_HOME folder. Mine has a suffix amd64 because I am using 64bit kernel.
Now you can re-open your terminal and you can execute properly the "java", "javac", and "grails" command. You can now create your grails project and start coding. You don't need a particular IDE to develop in grails. A simple gedit will do.
If you wish to use an IDE, Spring Tool Suite is a good choice if you are familiar with Eclipse. It is however a little bit slow and sometimes clunky. If you can shell out some money, or if you are into open source, IntelliJ IDEA is the best Java and Grails IDE around!
Tags: environment variable, grails, grails home, java home, linux, linux mint, setup, ubuntu