Tuesday, August 21, 2012

Grails - Installing and Creating a project in Grails

Grails is not only a web framework but a complete development framework which runs on top of JVM.It uses convention over configuration which makes it different from most of the frameworks which require alot of XML configuration. There is no need to use XML to configure various things while creating an web app using Grails. When application is created initially using Grails, it creates various directories in the project which are meant for specific things. For example , it creates folders like spring,hiberante,domain,controller etc where the specific files should be placed and application will automatically pick those up.Also Grails provides utilities to create domain classes and controllers which gets created and also gets copied to the directories which are meant for them. Isn't this wonderful. This saves alot of development time and is the beauty of framework.

To move further we will be seeing how to :-
  1. Download Grails from web.
  2. Install Grails on local computer.
  3. Creating first Application on grails.
  4. Running the Application created in step 3 on local host .

So lets get started.

Download Grails from web
Go to http://grails.org/Download and download the latest release of Grails. At this point of time the latest release is Grails 2.1.0.

Install Grails on local computer
Follow the below mentioned steps :-
  • Extract the downloaded Grails distribution into a folder. 
  • Create a GRAILS_HOME environment variable that points to the path where the Grails archive was extracted.
  • Append the GRAILS_HOME\bin directory to the PATH environment variable.
  • After completing the above steps , open command prompt and check installation of Grails by typing below command
>grails -version

Below is the output of the above command.

Creating first Application on grails
Now our Grails is working fine, lets have a feel and create first project(webapp) in Grails.
For this go to the workspace folder (c:\workspace-grails) from the command prompt. After that to create a new project issue following command at the prompt.

>grails create-app helloworld

Below will be the output :-

The output mite be different if you haven't created/used Grails previously as it loads all the dependencies first.

After successful execution of above command you can see that there is a directory(project) created.
The directory is having various sub-directories for different types of files.

Running the Application
Now in order to run the newly created application , change directory to "helloworld".

Now in order to run the application, start the server by following command.

>grails run-app

Below is the command and output.

Access the http://localhost:8080/helloworld/ link and check that Application successfully.

So that is it. Grails is successfully installed on local computer and first project on Grails is up,running and ready to add some more functionality.

We will look how to add more functionality in this project in next post on Grails.

Hope you liked the post and had a feel of Grails.

Happy Learning !!


  1. BlueHost is the best web-hosting company for any hosting services you might need.

  2. Thanks and Regards. Oracle Apps R12 Training Videos at affordable cost. please check oracleappstechnical.com