Grails Cookbook - A collection of tutorials and examples

Grails Tutorial for Beginners - Setup Your Windows Development Environment

For most beginners, one of the hardest part in learning a new technology, is to setup their development environment. This tutorial is written to help new Grails programmers to prepare their Windows Development Environment.

Overview

These are the steps for this guide.
  • Install JDK
  • Install Grails
  • Setup Environment Variables
  • Install Groovy/Grails Tool Suite
  • Configure Groovy/Grails Tool Suite
  • Create and Run a Sample Application

Install JDK

Since Grails runs on top of the Java platform, having the Java Development Kit (JDK) in your system is a requirement. For better compatability, I recommend using the JDK version 1.6. As of the time of this writing, JDK 1.7 is already available, but have some minor issues with Grails.
Go to Oracle website and download the JDK installer file. (http://www.oracle.com/technetwork/java/javase/downloads/jdk6u38-downloads-1877406.html)

p100
Just run and follow instructions
p101

Install Grails

Go to Grails website and download the latest version of Grails. (http://grails.org)
p102
And just extract it in your C drive:
p103

Setup Environment Variables

You need to setup your environmet variables. You need to specify the JAVA_HOME, GRAILS_HOME, and the path to their executable programs.
p104
p105
  • JAVA_HOME - is the directory where you installed the JDK. For example: C:\Program Files\Java\jdk1.6.0_38
  • GRAILS_HOME - is the directory where you extracted Grails. For example: C:\grails-2.2.3
  • PATH - Append the executable (bin) directories to the end of the previous value. For example: %PATH%;C:\Program Files\Java\jdk1.6.0_38\bin;C:\grails-2.2.3\bin
You can test if everything is fine by going to command line and issue "javac -version" and "grails -version" command:
p106

Install Groovy/Grails Tool Suite

This step is optional, as you can use just notepad and command line to develop Grails applications. But having an IDE is very convenient. One of the most used free IDE for Grails developmet is Groovy/Grails Tool Suite. Just go to the website and download. (http://www.springsource.org/downloads/sts-ggts)

p107
And extract to your C drive:
p108
Now you can run the program. For example run C:\springsource\ggts-3.3.0.RELEASE\GGTS.exe:
p109
And it should look like this:
p110

Configure Groovy/Grails Tool Suite

We have to make sure that the Java run time of our IDE points to a JDK instead of a JRE. Here are the steps:
Go to Preferences:
p111
Edit Installed JRE if it is pointing to a JRE installation:
p112
Change it to the JDK installation directory installed in the steps above. It is better if you also change the Name:
p113
p114
Make sure you have an installed Grails SDK:
p115

Create and Run a Sample Application

To validate that everything is properly working, we will create a sample project and run it.
From the File Menu, create a new Grails Project:
p116
Give it a name (e.g. sample) and click finish:
p117
The project will be created with default skeleton directories and files.
p118
Open Grails Console:
p119
Type "run-app" and hit the Enter key
p120
Check the console and wait for the message "Server running".
p121
Now you can open the application in your browser to test:
p122
As you can see, by default the skeleton program have a working screen. Complete with styles and some logic. I will add more tutorials on how to use Grails in the future.

List of Tutorials for Beginners

Tags: beginner, eclipse, ggts, grails tool suite, ide, jdk, setup, tutorial, windows