Setting Up Development Environment For Grails on GNU/Linux
In couple of my previous posts, I have explained how to install Grails and required packages to get a Grails development environment on the Windows platform. Continuing the Grails series, the current post explains how to set up a development environment for Grails web application framework on a GNU/Linux distribution. An alternative easier but less flexible method is noted to at the bottom of the post.
To setup Grails development environment on your GNU/Linux box, you first need to install Java SDK and Groovy packages.
-
Install Sun Java SDK 6 according to the instructions for your GNU/Linux distribution.
- For example, in Ubuntu you can install it like this:
- Make sure that the multiverse respository is enabled. Go to System -> Adminstration -> Synaptic Package Manager.
- In Synaptic Package Manager, go to Settings -> Repositories.
- Enable the multiverse repository if not already enabled.
- Click the Close button. Click Reload button on the toolbar to reload the package list.
- In Synaptic Package Manager, search for the “jdk” package(use Edit -> Search or Search button on the toolbar).

Scroll down the result list until you find Sun JDK 6 package, then right-click on it and select “Mark for installation.”

Click the Apply button on the toolbar to install the Sun JDK package.
You can also install it from the command line in one simple step:
# sudo aptitude install sun-java6-jdkYou can similarly use ‘emerge’ command in Gentoo, ‘yum’ command in Fedora GNU/Linux distributions. You can also simply download the compressed Sun JDK 6 binary archive for GNU/Linux, uncompress it in the home directory and set its bin directory in the PATH environment variables. For more information, read Sun’s JDK 6 installation notes for GNU/Linux(Yes, it’s ugly).
- To confirm that Java is installed and available in the system path, run the following commands:
tabrez@tabrez-ubuntu-vm:~$ java -version ; javac -version
java version “1.6.0_06″
javac 1.6.0_06 - Create a new system environment variable in your profile file (e.g. $HOME/.profile or /etc/.profile or /etc/environment – whatever you prefer the most) called JAVA_HOME and set it to your Java SDK installation directory path.
export JAVA_HOME=/usr/lib/jvm/java-6-sun/
Run the source command to apply the profile changes to the environment immediately without needing a session or OS restart.
# source $HOME/.profile
# echo $JAVA_HOME
/usr/lib/jvm/java-6-sun/
- For example, in Ubuntu you can install it like this:
-
Download and configure Groovy package.

Download the compressed archive package of Groovy from its download page to your home directory and uncompress it.#cd $HOME
# wget http://dist.groovy.codehaus.org/distributions/groovy-binary-1.5.6.zip
# unzip groovy-binary-1.0.2.zip
# mv groovy-binary-1.0.2 grails(Remember to download the latest stable version available on the Groovy download page.)
Create GROOVY_HOME environment variable in your profile file(just like you created the JAVA_HOME variable) and set it to the directory where you have uncompressed the Groovy package. Add Groovy’s bin directory to the PATH environment variable
export GROOVY_HOME=/home/tabrez/groovy/
export PATH=$PATH:$GROOVY_HOME/binCheck the version of Groovy.
# groovy -v
Groovy Version: 1.5.6 JVM: 10.0-b22 -
Download and configure Grails package.

Download the compressed archive package of Grails from its download page to your home directory and uncompress it.#cd ~
# wget http://dist.codehaus.org/grails/grails-bin-1.0.3.zip
# unzip grails-bin-1.0.3.zip
# mv grails-bin-1.0.3 grails(Remember to download the latest stable version available on the Grails download page. You can also download the compressed tar version(.tar.gz) if you don’t have the unzip command installed on your distribution.)
Create GRAILS_HOME environment variable and set it to the directory where you have uncompressed the Grails package(just like you created the JAVA_HOME variable). Add Grails’s bin directory to the PATH environment variable.
export GRAILS_HOME=/home/tabrez/grails/
export PATH=$PATH:$GROOVY_HOME/bin:$GRAILS_HOME/binMake the grails command executable and check the version of Grails.
# cd $HOME
# chmod +x grails/bin/grails
# grails -v
Welcome to Grails 1.0.2 – http://grails.org/ -
Testing the Grails Development Environment on GNU/Linux.
Now go to the post that explains how to create a Grails “Hello, World” web application to test if your Grails development environment is properly setup. It is for the Windows platform but I think that you should be able to adapt it to other platforms too. If you get into any problems, check if all the environment variables are properly set.

You can also post the error messages that you are getting somewhere on the Internet and provide the link to it in the comment section below. -
Next: Alternative easy way to set up Grails development environment using package managers
There is also an easy way to setup Grails development environment using the package managers of different GNU/Linux distributions. Like installing Groovy and Grails packages in Ubuntu using the apt-get command. This easy model has certain limitations though like support only for old versions of Java, Groovy and/or Grails.
I will discuss more about it in the next post.Done.
[...] I have covered the installation procedure of Grails framework in my previous posts: Setting Up Development Environment For Grails on Windows Vista/XP and Setting Up Development Environment For Grails on GNU/Linux. [...]
QuotePingback by Creating “Hello World” Web Application Using the Grails Framework — July 10, 2008 @ 3:05 pm
[...] Groovy/Grails, Ubuntu — tabrez @ 3:21 pm In my previous post I talked about setting up Grails development environment in GNU/Linux distributions by manually downloading the packages and configuring the environment variables. The main advantage [...]
QuotePingback by Installing Grails in Ubuntu GNU/Linux Using Package Manager — July 14, 2008 @ 3:21 pm