Archive for June, 2008
Setting Up Development Environment For Grails on Windows Vista/XP
11Just as Ruby on Rails started to get wide publicity in the media for providing a surprisingly productive web application development framework, many people using other web development technologies suddenly started to wonder if their environment is missing something. Some introspection later, while some tried to add more productive features to their favourite technologies, some others went ahead and committed themselves to create a Ruby on Rails like framework for their own favourite programming language or platform. Where frameworks like TurboGears, Django come close to the model of Ruby on Rails and provided an excellent alternative for the Python programmers, one framework that comes the closest, in my opinion, is the Grails framework, and what good news it is for the Groovy and Java guys looking for an alternative way of developing web applications.
While Grails may yet lack the complete feature set and level of support available for the Ruby on Rails framework, it is very much a stable framework now and currently used by many websites in production environment. Below is the procedure to get everything needed to start creating web applications in Groovy using the Grails framework.
- Download and install the latest version of Java SE(currently JDK 6 update 6).
Skip to the next step if you plan to use NetBeans or some other IDE. If you want to work with a text editor and the command prompt, you need to set the following environment variables:
Go to Control Panel -> System -> Advanced System Settings and click the “Environment Variables” button. (Or Control Panel -> System, select the Advanced tab and click the “Environment Variables” button if you are using Windows XP).Add the path to Java bin directory to the system PATH variable.
Add a new system environment variable called JAVA_HOME and set it to the path to your Java installation directory.

For more details, refer to Sun’s instructions on how to install Java SE. - Download and install the latest stable version of the Groovy windows installer(currently 1.5.6).

Make sure that you install Groovy to a path that doesn’t contain any spaces in it; so you need to remember to change the default path in the installer from “C:\Program Files\Groovy” to something like “C:\groovy”. Also make sure that you select the checkboxes to add Groovy’s directories to system environment variables.


For all the other settings, you can just accept the defaults. To confirm that Groovy is installed and all the environment variables are properly set, run the following command in the command prompt:
C:\> groovy -v
Groovy Version: 1.5.6 JVM: 10.0-b22If you get an error instead, carefully check again that the environment variables PATH and GROOVY_HOME are properly set.
- Repeat the similar process with the Grails installer: Download the latest stable version of the Grails installer and run it.

Unlike the Groovy installer, Grails installer doesn’t create any environment variables, so we have to create them manually. Create a new environment variable called GRAILS_HOME and set it to the Grails installation path.

Also add Grails’s bin directory to the PATH system environment variable:
PATH=%JAVA_HOME%\bin;%GROOVY_HOME%\bin;%GRAILS_HOME%\binTo make sure that Grails is installed and the environment variables are set properly, run the following command:
C:\Users\tabrez>grails -vWelcome to Grails 1.0.2 – http://grails.org/
Licensed under Apache Standard Li
Grails home is set to: C:\grails - Now proceed to the next part of this tutorial and create an example “Hello World” web application using Grails framework to validate your Grails installation on Windows operating system.
Setting Up Rails Development Environment on Windows Vista/XP
19There are different ways in which you might want to set up a complete development environment for Ruby on Rails on a Windows machine. I am going to cover how to setup Rails on a Windows machine using Ruby, RubyGems, Rails, Mongrel, MySQL, NetBeans and Subversion as part of the development stack. I will be using Windows Vista as the reference OS but most of the instructions work for Windows XP too.
- Installing Ruby: Download and install the latest final version of the Ruby installer(currently 1.8.6) from the rubyforge.net website: One-Click Ruby Installer for Windows
Leave all the default settings as they are and proceed with the installation wizard. It is important that you install Ruby in a path which doesn’t contain any spaces in it(the path c:\ruby selected in the wizard by default works fine).
After the installation is complete, confirm that the ruby commands are added to the system path. Start the Command Prompt(Start -> Accessories -> Command Prompt) and type the following command:
C:\> ruby -v
ruby 1.8.6 (2007-09-24 patchlevel 111) [i386-mswin32]
C:\> gem -v
0.9.4If you get the “not recognized as an internal or external command” error, add the path to the ruby bin directory(e.g. c:\ruby\bin) to the system PATH environment variable(Control Panel -> System -> Advanced System Settings).
- Updating RubyGems:
The above installer also installs RubyGems package and SciTE editor as part of the “one-click” installation process. Unfortunately though, the installed version of RubyGems may be a bit old(~0.9.4), so run the following command to update it to the latest available version(currently 1.1.1):C:\> gem update ––system
C:\> gem -v
1.1.1Note: Add “-p http://proxy:port” to all gem install commands if you are connecting to the Internet through a proxy.
- Installing Rails:
Now it is time to install the Rails package. Run the following command to install Rails as a ruby gem:C:\> gem install rails
C:\> rails -v
2.1.0In future, whenever you want to update Rails to a newer version, simply run the following command:
C:\> gem update rails
The basic Rails development environment is now installed on your system and you can skip the rest of the post if you are happy with WEBrick as the web server, SQLite as the database server and SciTE as the editor(or your favourite text editor/IDE already installed on your system). The following instructions cover installing an alternate web server called Mongrel; MySQL database server and its GUI tools; NetBeans IDE, Subversion and their integration.
- Installing Mongrel:
Installing the Rails gem also installs the WEBrick web server which is ideally suited for development purposes. Another much recommended web server for Rails development as well as production environment is the Mongrel web server. To install the Mongrel web server, run the following gem command:C:\> gem install mongrel
C:\> gem list mongrel*** LOCAL GEMS ***
mongrel (1.1.5)
After installing Mongrel, Rails automatically starts the Mongrel instead of WEBrick web server when you run the Rails applications in development mode. (Refer to Mongrel documentation to know more about runing Rails applications under Mongrel in production mode.)
- Installing MySQL:
This step covers the installation of MySQL database server and its GUI tools. Skip this step if you want to use some other database server.Download and install the MySQL 5 database server. You can safely accept all the default settings of the installation wizard. After MySQL database server is installed, you need to run its configuration wizard to configure the MySQL installation.
- If you are a Windows XP user, run the configuration wizard directly from Start -> MySQL -> MySQL Server 5.0 -> MySQL Server Instance Config Wizard.
- If you are a Windows Vista user, you first need to patch the configuration wizard before running it. Follow these instructions to patch the MySQL configuration executable using ResHack utility. Once that is done, you can run the configuration wizard from Start -> MySQL -> MySQL Server 5.0 -> MySQL Server Instance Config Wizard.
One important step during the configuration process is to select a root password(you will need to enter it in the database.yml configuration file of your Rails application).
Now download and install the MySQL GUI tools. This step can be skipped if you want to use mysql command line tools or if you prefer other GUI front-ends like HeidiSQL.
- Installing Netbeans:
You can use your favourite text editor or IDE to code your Rails application. Two of the most popular, Free Rails IDEs are NetBeans and Eclipse. NetBeans in particular has shown great improvement in its support for Ruby programming language and the Rails framework. I am going to cover configuring Netbeans for developing applications with Rails, so feel free to skip this step if you want to go with some other IDE(Aptana, IntelliJ IDEA etc.).Go to the download page of Netbeans IDE and download either the “Ruby” version(~29MB) or the “All” version(~219MB). (Ruby version supports only Ruby where as the All version supports Java, C++, etc. in addition to Ruby.)
Install NetBeans. Run it. When creating a new Rails project in NetBeans, remember to select “Ruby” as the default instead of the default “JRuby” and then select Mongrel as the web server.

For more information on developing Ruby on Rails applications using the NetBeans IDE, refer to the following links:
There are many alternative IDEs that you can checkout, like Aptana Studio, Komodo, IntelliJ IDEA, etc.
- Installing Subversion:
Go to the Subversion download page, scroll down to the Windows section and click the “Win32 packages built against Apache 2.2″ link and download and install the ‘basic win32 binaries’ package.

You can now work with the Rails applications stored in subversion repositories. You can also install and use TortoiseSVN which is a GUI subversion client that integrates very well with the Windows Explorer. I couldn’t find a way to integrated it with NetBeans though, so I install the subversion command line version to use with NetBeans even if I have TortoiseSVN installed on my system.
- Configuring Subversion in NetBeans:
Start the NetBeans IDE and go to Versioning -> Subversion -> Checkout. If you see a dialog box as shown in the screenshot below, it means subversion is properly installed and configured on your system. You can enter the repository details in the fields shown by the wizard, checkout a Rails application and work on it from the NetBeans IDE.
(If you see an error instead, then you need to either add the subversion bin directory to the system PATH variable or enter the path in the shown NetBeans configuration window.)
NetBeans has direct support for CVS, Subversion and Mercurial and NetBeans support for Git is currently under development.
Now you can create/checkout rails applications, edit them and run them under Mongrel from within the NetBeans IDE. One crucial item missing from this development environment is an alternative, more powerful automated build tool CruiseControl, which can also be integrated with NetBeans. Perhaps a topic for another post. In the next post I will explain how to create a basic “Hello World” application in Rails using the above development tools.
Recent Comments