Just as Ruby on Rails started to get wide publicity in the media for providing a surprisingly productive web application development framework, many people using other web development technologies suddenly started to wonder if their environment is missing something. Some introspection later, while some tried to add more productive features to their favourite technologies, some others went ahead and committed themselves to create a Ruby on Rails like framework for their own favourite programming language or platform. Where frameworks like TurboGears, Django come close to the model of Ruby on Rails and provided an excellent alternative for the Python programmers, one framework that comes the closest, in my opinion, is the Grails framework, and what good news it is for the Groovy and Java guys looking for an alternative way of developing web applications.

While Grails may yet lack the complete feature set and level of support available for the Ruby on Rails framework, it is very much a stable framework now and currently used by many websites in production environment. Below is the procedure to get everything needed to start creating web applications in Groovy using the Grails framework.

  1. Download and install the latest version of Java SE(currently JDK 6 update 6).
    Skip to the next step if you plan to use NetBeans or some other IDE. If you want to work with a text editor and the command prompt, you need to set the following environment variables:
    Go to Control Panel -> System -> Advanced System Settings and click the “Environment Variables” button. (Or Control Panel -> System, select the Advanced tab and click the “Environment Variables” button if you are using Windows XP).

    Add the path to Java bin directory to the system PATH variable.
    Add a new system environment variable called JAVA_HOME and set it to the path to your Java installation directory.
    Set Java environment variables in Windows
    For more details, refer to Sun’s instructions on how to install Java SE.

  2. Download and install the latest stable version of the Groovy windows installer(currently 1.5.6).
    Download the latest stable version of Groovy windows isntaller
    Make sure that you install Groovy to a path that doesn’t contain any spaces in it; so you need to remember to change the default path in the installer from “C:\Program Files\Groovy” to something like “C:\groovy”. Also make sure that you select the checkboxes to add Groovy’s directories to system environment variables.
    Select install path for Groovy that contains no spaces in it
    Select install path for Groovy that contains no spaces in it
    Select environment variables to be created by the Groovy windows installer

    For all the other settings, you can just accept the defaults. To confirm that Groovy is installed and all the environment variables are properly set, run the following command in the command prompt:

    C:\> groovy -v
    Groovy Version: 1.5.6 JVM: 10.0-b22

    If you get an error instead, carefully check again that the environment variables PATH and GROOVY_HOME are properly set.

  3. Repeat the similar process with the Grails installer: Download the latest stable version of the Grails installer and run it.
    Download the latest stable version of Grails Windows Installer
    Unlike the Groovy installer, Grails installer doesn’t create any environment variables, so we have to create them manually. Create a new environment variable called GRAILS_HOME and set it to the Grails installation path.
    Set Grails HOME environment variable in Windows
    Also add Grails’s bin directory to the PATH system environment variable:
    PATH=%JAVA_HOME%\bin;%GROOVY_HOME%\bin;%GRAILS_HOME%\bin

    To make sure that Grails is installed and the environment variables are set properly, run the following command:

    C:\Users\tabrez>grails -v

    Welcome to Grails 1.0.2 – http://grails.org/
    Licensed under Apache Standard Li
    Grails home is set to: C:\grails

  4. Now proceed to the next part of this tutorial and create an example “Hello World” web application using Grails framework to validate your Grails installation on Windows operating system.