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.
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
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)
Just run and follow instructions
Go to Grails website and download the latest version of Grails. (http://grails.org)
And just extract it in your C drive:
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.
- 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:
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)
And extract to your C drive:
Now you can run the program. For example run C:\springsource\ggts-3.3.0.RELEASE\GGTS.exe:
And it should look like this:
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:
Edit Installed JRE if it is pointing to a JRE installation:
Change it to the JDK installation directory installed in the steps above. It is better if you also change the Name:
Make sure you have an installed Grails SDK:
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:
Give it a name (e.g. sample) and click finish:
The project will be created with default skeleton directories and files.
Open Grails Console:
Type "run-app" and hit the Enter key
Check the console and wait for the message "Server running".
Now you can open the application in your browser to test:
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