Installing Grails for the first time

Installing Grails

Before installing grails, we will discuss about what grails is in general detail, Grails is an open source web application framework that uses the Groovy programming language based on the Java platform. Grails embraces concepts such as Convention over Configuration, Don’t Repeat Yourself (DRY), and an array of domain-specific languages (DSLs) that make your projects more easier. Grails is powered by some of the most popular open source technologies in their respective categories:

  • Hibernate: The de facto standard for object-relational mapping (ORM) in the Java world.
  • Spring: The hugely popular open source Inversion of Control (IoC) container and wrapper framework for Java.
  • SiteMesh: A robust and stable layout-rendering framework.
  • Tomcat: A proven, embeddable servlet container.
  • H2: A pure Java Relational Database Management System implementation.

1. Installing Grails :

Before installing Grails 3.0 you will need as a minimum a Java Development Kit (JDK) installed version 1.7 or above. To automate the installation of Grails we recommend SDKMAN which greatly simplifies installing and managing multiple Grails versions.

Java : 1.7.0_25
grails: 3.2.5
groovy: 2.1.9
Versions used in this tutorial

Run following command to install SDKMAN using terminal :

$ curl -s "https://get.sdkman.io" | bash

follow all the given instructions displayed on the terminal screen, to complete the installation.

When completed open a new terminal window and check sdk version installed using command below :

$ sdk version

then install grails :

$ sdk install grails 3.2.5

after installation check grails version :

$ grails -version

2. Creating an Application in grails :

To create a grails app we use grails create-app command.

Let’s create a grails app called helloworld

$ grails create-app helloworld

this will create a helloworld directory with project files in your home folder

now change directory to helloworld

$ grails cd helloworld

then run grails command in your project directory, this will open so called grails interactive mode

$ grails

In interactive mode type

run-app press enter following message is displayed

Grails application running at http://localhost:8080 in environment: development

Now open your browser and navigate to http://localhost:8080

grails run-app