I've been meaning to do this for a while, but I wanted to put together a series of posts that help people get started with Grails, even when they have limited experience of J2EE and surrounding technologies (such as Spring and Hibernate).
There is now an increasing amount of documentation surrounding Grails, much of it excellent (I'm a particularly big fan of Grails in Action). However, lots of the artciles assume a base level of knowledge and experience with Java, Groovy, Spring, Hibernate, etc.
When I first started using Grails I had very little experience with many of these, apart from standard JDK - as a result I struggled with the learning curve to get up to speed with so many different technoligies all at once.
Grails does a fantastic job of hiding the complexities of many of these underlying technoligies through its adoption of 'convention-over-configuration', but inevitably there comes a time in any non-trivial application when you need to pull back the covers and change the default way Grails does things - this is where I started to find things quite challenging!
Consequently these articles will start by assuming you know relatively little about Java, J2EE, Groovy, Grails, Spring and so on, although I will assume the following:
- That you have some programming experience.
- Ideally Java, Ruby or similar, but any modern object-orientated language should do.
- It would also be an advantage if you were familiar with the Model-View-Controller design pattern.
- This is the architecture on which Grails is based.
- That you can download, install and configure applications on your computer.
We will create a simple project using Grails in these posts - my environment will be based on a completely clean Windows XP Pro (SP3) desktop. I realise that this is a bit boring and somewhat dated, but it's still very common and provides a well-supported platform on which to build our project - it'll also minimise environmental distractions. Feel free to use a different operating-system, but you're on your own in terms of configuring it.
For this first post we'll simply get things set up - to start with we need to download a number of applications and packages:
Please don't be put off - you don't need to download and install all of these right away and don't worry too much about getting the exact versions either:
The first thing you'll need to install is the Java JDK, followed by J2EE. Once these are in place you will need to unzip the Grails download to a suitable place - I usually place it in a directory called 'grails' from the root of the drive:
Once unzipped you need to set a couple of environment variables:
- JAVA_HOME
- GRAILS_HOME
Set JAVA_HOME to the directory in which you installed the JDK and GRAILS_HOME to the directory into which you installed Grails:
That should be it - open a command-print (Start -> Run -> cmd) and type the following:
- java -version
If Java is setup correctly you should get some sensible output telling you about the version of Java that you're using:
Following this type the following to check Grails:
- grails -version
Grails doesn't actually recognise the '-version' switch, but if everything is setup correctly you should see something sensible output, including information about the version of Grails that is installed:
If you try to run Grails without setting the environment variables you will see something like this:
That's all you actually need to get started - in the next posting we will step through creating an application via the command-line, after which we'll change to using an Integrated Development Environment (IDE) which makes life much easier - this is there Netbeans comes in.

0 comments:
Post a Comment