Every Flavour Beans

“The time has come…to talk of many [technologies].” –Lewis Carroll(‘The Walrus and the Carpenter’)
Development Tools. Web Frameworks. GNU/Linux. Nokia N800. Video Encoding.

July 10, 2008

Setting Up Development Environment For Grails on GNU/Linux

Filed under: GNU/Linux, Groovy/Grails, Java, Web — tabrez @ 2:32 pm

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.

  1. Install Sun Java SDK 6 according to the instructions for your GNU/Linux distribution.

    1. 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.
        Enable multiverse and universe repositories in Ubuntu GNU/Linux to see all installable packages.
      • 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).
        Search for Sun JDK 6 package in Synaptic Package Manager in Ubuntu GNU/Linux.
        Scroll down the result list until you find Sun JDK 6 package, then right-click on it and select “Mark for installation.”
        Mark Sun JDK 6 package in Synaptic Package Manager 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-jdk

      You 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).

    2. 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
    3. 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/
  2. Download and configure Groovy package.

    Download the stable version of 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/bin

    Check the version of Groovy.

    # groovy -v
    Groovy Version: 1.5.6 JVM: 10.0-b22
  3. Download and configure Grails package.

    Download the stable version of 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/bin

    Make 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/
  4. 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.
    Make sure that you have setup the JAVA_HOME, GROOVY_HOME, GRAILS_HOME environment variables correctly to get working Grails development environment.
    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.

  5. 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.


If you want to receive future posts by email, enter your email address here:

Related Posts:

  • Creating “Hello World” Web Application Using the Grails Framework
  • Installing Grails in Ubuntu GNU/Linux Using Package Manager
  • Setting Up Development Environment For Grails on Windows Vista/XP
  • Setting Up Rails Development Environment on Fedora GNU/Linux
  • “Hello, World” Web Application in Ruby on Rails using console
  • Installing Sun Java SE 6, Apache Maven 2 and Tomcat 5.5 on Ubuntu GNU/Linux
  • Setting Up Rails Development Environment on Ubuntu GNU/Linux


  • 2 Comments »

    1. [...] 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. [...]

      Quote

      Pingback by Creating “Hello World” Web Application Using the Grails Framework — July 10, 2008 @ 3:05 pm

    2. [...] 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 [...]

      Quote

      Pingback by Installing Grails in Ubuntu GNU/Linux Using Package Manager — July 14, 2008 @ 3:21 pm

    RSS feed for comments on this post. TrackBack URI

    Leave a comment


    Copyright (c) 2006, 2007 Tabrez Iqbal.
    Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. Verbatim copying and distribution of this entire article is permitted in any medium without royalty provided this notice is preserved. A copy of the license is included in the section entitled "GNU Free Documentation License".


    Powered by WordPress
    This website is hosted by Dreamhost