Groovy/Grails

Installing Grails in Ubuntu GNU/Linux Using Package Manager

2

In my previous post I talked about setting up Grails development environment in GNU/Linux distributions by manually downloading the packages and configuring the environment variables. The main advantage of this method is that you can work with the latest versions of the Groovy and Grails packages available, and in fact, you can work with more than one version of these software at the same time: just point your environment variables to different locations. The procedure is also more or less independent of a particular GNU/Linux distribution.

An easier, alternative way to install Groovy and Grails packages is to use the package management system of your favourite GNU/Linux distribution. The trade-off is that you have to accept the version of the packages that are available in your distribution’s repositories(apt-get) or you may have to compromise with the stability of your system(dpkg). Below I am documenting the procedure to install Grails development environment using package manager tools in Ubuntu 8.04(Hardy Heron).

  1. Installing Sun JDK 6 in Ubuntu 8.04 Using apt-get/aptitude

    In Debian/Ubuntu based operating systems installing new packages is as simple as running aptitude command with the package name.

    # sudo aptitude install sun-java6-jdk

    You also need to set JAVA_HOME environment variable in your preferred profile file(/etc/profile, $HOME/.profile or /etc/environment):

    JAVA_HOME=/usr/lib/jvm/java-6-sun

    Refer to the first step of previous post in my Grails series if you need more help.

    1. Installing Groovy in Ubuntu 8.04 Using apt-get/aptitude

      To install Groovy and its dependency packages, run the following command in a command shell:

      # sudo aptitude install groovy

      You can also install Groovy from Synaptic Package Manager, simply search for package name called “groovy” in it. But have a look at the version number!

      Synaptic Package Manager shows an old version of Groovy package in Ubuntu 8.04 package repository

      See what I mean? The latest stable version of Groovy is 1.5.6 though I would recommend using the 1.6 beta 1.

    2. Installing Groovy in Ubuntu 8.04 Using GDebi

      If you don’t mind picking up a deb file from a third-party source, Groovy download page has Debian/Ubuntu packages for both 1.5.6 stable version and 1.6 beta 1 version.

      Groovy latest stable version for Debian/Ubuntu family of GNU/Linux distributions available as a deb package.

      When you download the Ubuntu deb binary from this page Ubuntu will automatically open it using GDebi and install it for you.

      Download the Groovy deb package from its download page and install it with GDebi application.

    3. Installing Groovy in Ubuntu 8.04 Using dpkg

      You can also save the deb file on your computer and install it from the command shell using the dpkg tool:

      # sudo dpkg -i <name-of-the-downloaded-deb-file>
    1. Installing Grails in Ubuntu 8.04 Using apt-get/aptitude

      Unfortunately there is no Grails package in Ubuntu official repositories yet. You can try any unofficial repositories for Grails available on the Internet but only if you trust them. An old repository meant for installing Grails 1.0 RC2 on Ubuntu Gutsy was posted on Ubuntu Forums by prach. Have a look at it just as an example, I don’t recommend actually using it. I don’t know of a similar repository for more recent versions of Grails. So better option will be to install the latest deb package of Grails using GDebi or dpkg tools; see the next step.

    2. Installing Grails in Ubuntu 8.04 Using GDebi

      You can follow the above procedure(Step 2(b)) used for Groovy to install Grails too, by downloading its deb package from Grails’s download page.

      Download the Groovy deb package from its download page and install it with GDebi application.

      Then choose to open the package with GDebi installer.

      Download the Grails deb package from its download page and install it with GDebi application.

    3. Installing Grails in Ubuntu 8.04 Using dpkg

      You can also save the deb file on your computer and install it from the command shell using the dpkg tool:

      # sudo dpkg -i <name-of-the-downloaded-deb-file>
  2. You can now go to the post where I show how to create a basic “Hello, World” Grails application to test your Grails configuration. (You can ignore the first step of that post.)

Summary:
To summarize, you can install Sun JDK, Groovy and Grails packages in Debian/Ubuntu family of distributions using simple commands, like this:

# sudo aptitude install sun-java6-jdk
# sudo echo ‘JAVA_HOME=/usr/lib/jvm/java-6-sun’ >> /etc/profile
# wget http://dist.codehaus.org/groovy/distributions/installers/deb/groovy-1.6-beta-1.deb
# sudo dpkg -i groovy-1.6-beta-1.deb
# wget http://ant-deb-task.googlecode.com/files/grails_1.0.3-1_all.deb
# sudo dpkg -i grails_1.0.3-1_all.deb

You can use similar commands/tools for other GNU/Linux distributions, like yum in Fedora, yast in openSUSE, emerge in Gentoo, etc. All the above download links point to the latest versions at the time of this writing, so remember to change them appropriately when updated versions are released.

Setting Up Development Environment For Grails on GNU/Linux

3

In couple of my previous posts, I have explained how to install Grails and required packages to get a Grails development environment on the Windows platform. Continuing the Grails series, the current post explains how to set up a development environment for Grails web application framework on a GNU/Linux distribution. An alternative easier but less flexible method is noted to at the bottom of the post.

To setup Grails development environment on your GNU/Linux box, you first need to install Java SDK and Groovy packages.

  1. Install Sun Java SDK 6 according to the instructions for your GNU/Linux distribution.

    1. For example, in Ubuntu you can install it like this:
      • Make sure that the multiverse respository is enabled. Go to System -> Adminstration -> Synaptic Package Manager.
      • In Synaptic Package Manager, go to Settings -> Repositories.
      • Enable the multiverse repository if not already enabled.
        Enable multiverse and universe repositories in Ubuntu GNU/Linux to see all installable packages.
      • Click the Close button. Click Reload button on the toolbar to reload the package list.
      • In Synaptic Package Manager, search for the “jdk” package(use Edit -> Search or Search button on the toolbar).
        Search for Sun JDK 6 package in Synaptic Package Manager in Ubuntu GNU/Linux.
        Scroll down the result list until you find Sun JDK 6 package, then right-click on it and select “Mark for installation.”
        Mark Sun JDK 6 package in Synaptic Package Manager for installation.
        Click the Apply button on the toolbar to install the Sun JDK package.

      You can also install it from the command line in one simple step:

      # sudo aptitude install sun-java6-jdk

      You can similarly use ‘emerge’ command in Gentoo, ‘yum’ command in Fedora GNU/Linux distributions. You can also simply download the compressed Sun JDK 6 binary archive for GNU/Linux, uncompress it in the home directory and set its bin directory in the PATH environment variables. For more information, read Sun’s JDK 6 installation notes for GNU/Linux(Yes, it’s ugly).

    2. To confirm that Java is installed and available in the system path, run the following commands:
      tabrez@tabrez-ubuntu-vm:~$ java -version ; javac -version
      java version “1.6.0_06″
      javac 1.6.0_06
    3. Create a new system environment variable in your profile file (e.g. $HOME/.profile or /etc/.profile or /etc/environment – whatever you prefer the most) called JAVA_HOME and set it to your Java SDK installation directory path.

      export JAVA_HOME=/usr/lib/jvm/java-6-sun/

      Run the source command to apply the profile changes to the environment immediately without needing a session or OS restart.

      # source $HOME/.profile
      # echo $JAVA_HOME
      /usr/lib/jvm/java-6-sun/
  2. Download and configure Groovy package.

    Download the stable version of Groovy package.
    Download the compressed archive package of Groovy from its download page to your home directory and uncompress it.

    #cd $HOME
    # wget http://dist.groovy.codehaus.org/distributions/groovy-binary-1.5.6.zip
    # unzip groovy-binary-1.0.2.zip
    # mv groovy-binary-1.0.2 grails

    (Remember to download the latest stable version available on the Groovy download page.)

    Create GROOVY_HOME environment variable in your profile file(just like you created the JAVA_HOME variable) and set it to the directory where you have uncompressed the Groovy package. Add Groovy’s bin directory to the PATH environment variable

    export GROOVY_HOME=/home/tabrez/groovy/
    export PATH=$PATH:$GROOVY_HOME/bin

    Check the version of Groovy.

    # groovy -v
    Groovy Version: 1.5.6 JVM: 10.0-b22
  3. Download and configure Grails package.

    Download the stable version of Grails package.
    Download the compressed archive package of Grails from its download page to your home directory and uncompress it.

    #cd ~
    # wget http://dist.codehaus.org/grails/grails-bin-1.0.3.zip
    # unzip grails-bin-1.0.3.zip
    # mv grails-bin-1.0.3 grails

    (Remember to download the latest stable version available on the Grails download page. You can also download the compressed tar version(.tar.gz) if you don’t have the unzip command installed on your distribution.)

    Create GRAILS_HOME environment variable and set it to the directory where you have uncompressed the Grails package(just like you created the JAVA_HOME variable). Add Grails’s bin directory to the PATH environment variable.

    export GRAILS_HOME=/home/tabrez/grails/
    export PATH=$PATH:$GROOVY_HOME/bin:$GRAILS_HOME/bin

    Make the grails command executable and check the version of Grails.

    # cd $HOME
    # chmod +x grails/bin/grails
    # grails -v
    Welcome to Grails 1.0.2 – http://grails.org/
  4. Testing the Grails Development Environment on GNU/Linux.

    Now go to the post that explains how to create a Grails “Hello, World” web application to test if your Grails development environment is properly setup. It is for the Windows platform but I think that you should be able to adapt it to other platforms too. If you get into any problems, check if all the environment variables are properly set.
    Make sure that you have setup the JAVA_HOME, GROOVY_HOME, GRAILS_HOME environment variables correctly to get working Grails development environment.
    You can also post the error messages that you are getting somewhere on the Internet and provide the link to it in the comment section below.

  5. Next: Alternative easy way to set up Grails development environment using package managers

    There is also an easy way to setup Grails development environment using the package managers of different GNU/Linux distributions. Like installing Groovy and Grails packages in Ubuntu using the apt-get command. This easy model has certain limitations though like support only for old versions of Java, Groovy and/or Grails. I will discuss more about it in the next post. Done.

Creating “Hello World” Web Application Using the Grails Framework

8
  1. I have covered the installation procedure of Grails framework in my previous posts:
    Setting Up Development Environment For Grails on Windows Vista/XP and GNU/Linux.

    Just to make sure, check out again if the following environment variables are set properly on your operating system.

    On Windows:
    Set Grails environment variables in Windows
    Set Java HOME environment variable in Windows
    Set Groovy HOME environment variable in Windows
    Set Grails HOME environment variable in Windows
    Set Grails PATH environment variables in Windows

    PATH should be set to something like(you can also check with ‘echo %PATH%’ on the command prompt):
    c:\ruby\bin;C:\Program Files (x86)\MySQL\MySQL Server 5.0\bin;C:\Program Files (x86)\Subversion\bin;%JAVA_HOME%\bin;%GROOVY_HOME%\bin;%GRAILS_HOME%\bin

    On GNU/Linux:

    # echo $JAVA_HOME :: $GROOVY_HOME :: $GRAILS_HOME
    /usr/lib/jvm/java-6-sun :: /home/tabrez/groovy :: /home/tabrez/grails
    # echo $PATH
    /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/home/tabrez/groovy/bin:/home/tabrez/grails/bin
  2. Now you are all set to create Grails applications from the command line using your favourite text editor. IDE integration support for Groovy and Grails is not that great at this moment, I will write more about it in the next post. Let me just walk you through the creation of a sample Grails application from the command line.

    Open the command prompt and run the following commands:

    # grails create-app hello
    [lot of text]
    Created Grails Application at C:\Users\tabrez\grails_apps/hello
    # cd hello && dir
    .classpath
    .project
    application.properties
    build.xml
    grails-app
    hello.launch
    hello.tmproj
    lib
    scripts
    src
    test
    web-app
    # grails create-controller hello
    [lot of text]
    Created ControllerTests for Hello
  3. Open hello/grails-app/controllers/HelloController.groovy using your favourite programming editor/IDE(e.g. SciTE, Emacs, Vim) and change its content to look like this:
    Hello World program in Grails and Groovy
  4. Run the web application and view it in the web browser.
    # grails run-app
    [lot of text]
    Server running. Browse to http://localhost:8080/hello
    2008-06-15 15:55:51.363:/hello:INFO: GSP servlet initialized

    Now our application is running at the specified url. To invoke the controller that we had written earlier(Step 3), open the following url in a web browser:

    http://localhost:8080/hello/hello/hello

    And you should see the following output.
    Grails Hello World program output in Web Browser
    (If you are confused about the url: the first hello is the name of the application, the second hello is the name of the controller and the third hello is the name of the action to be invoked. In non-hello-world applications, these three will be different from each other!)

That’s it. You have created and executed your first Grails web application. Next up is IDE integration.

Resources:
For more information, refer to the following resources:
1. Grails QuickStart Guide
2. Grails Tutorials and Screencasts
3. The Definitive Guide to Grails (Amazon)

Setting Up Development Environment For Grails on Windows Vista/XP

11

Just 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.

  1. 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.
    Set Java environment variables in Windows
    For more details, refer to Sun’s instructions on how to install Java SE.

  2. Download and install the latest stable version of the Groovy windows installer(currently 1.5.6).
    Download the latest stable version of Groovy windows isntaller
    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.
    Select install path for Groovy that contains no spaces in it
    Select install path for Groovy that contains no spaces in it
    Select environment variables to be created by the Groovy windows installer

    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-b22

    If you get an error instead, carefully check again that the environment variables PATH and GROOVY_HOME are properly set.

  3. Repeat the similar process with the Grails installer: Download the latest stable version of the Grails installer and run it.
    Download the latest stable version of Grails Windows Installer
    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.
    Set Grails HOME environment variable in Windows
    Also add Grails’s bin directory to the PATH system environment variable:
    PATH=%JAVA_HOME%\bin;%GROOVY_HOME%\bin;%GRAILS_HOME%\bin

    To make sure that Grails is installed and the environment variables are set properly, run the following command:

    C:\Users\tabrez>grails -v

    Welcome to Grails 1.0.2 – http://grails.org/
    Licensed under Apache Standard Li
    Grails home is set to: C:\grails

  4. 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.
buy prednisone medication COD purchase prednisone without prescription needed purchase prednisone prescription online prednisone no prior script prednisone no rx needed order prednisone usa cod buy prednisone without rx from us pharmacy buy prednisone online without rx purchase prednisone without prescription order prednisone saturday delivery buy prednisone amex online without prescription ordering prednisone over the counter buy prednisone amex online without rx where can i buy Prednisone ordering Paxil over the counter order Paxil without rx needed order Paxil pharmacy Paxil overnight delivery fed ex ordering Paxil without a script order Paxil order amex order Paxil amex online without prescription buy Paxil pay pal without prescription order rx free Paxil cheapest Paxil available online purchase Paxil without purchase Paxil without prescription how to order Paxil online without a prescription purchase Paxil cod next day delivery buy discount Paxil online buy Paxil no visa online without rx where to buy accutane buy frontpage software cheap mortgage application software buy autocad software best price for final draft 7 software iphone software download plagiarism software to buy for parents Crestor side effects buy masterwriter software discount bmi sesac microsoft software downloads wm5 software download treo software download cheap discount software xxasdf discount trellian software best antivirus software download cheap microsoft word software buy software for mac software discounts for educators microsoft office purchase Prednisone online no membership buy windows xp oem software buy flash cs3 software photoshop cs 5 full fashion conference italy buy Orlistat with amex ordering Lasix over the counter purchase online prescription Lasix without windows 7 product key purchase online cheapest xenical available online prescription xenical online online Maxalt achat Maxalt Valtrex with repronex where to buy Valtrex by cod where to purchase generic valtrex online without a prescription quality generic valtrex cheap valtrex usa (no prescriptions needed for Buspar|buy Buspar with no prescription|online pharmacies Buspar|Buspar cheap|buy Buspar without rx|purchase rx Buspar without|Buspar purchase online|purchase Buspar online without rx|purchase Buspar free consultation|buy Buspar Online|buy Buspar american express|buy Buspar Online|buy cheap Buspar with dr. prescription|Buspar side effects|fedex Buspar without priscription|overnight Buspar without a rx|order cheap overnight Buspar|Buspar toronto|uk order Buspar|Buspar no doctors prescription|Buspar mexico|Buspar order|no prescription Buspar with fedex|order generic Buspar|buy Buspar without rx from us pharmacy|prezzo Buspar|Buspar 10mg|Buspar from canada|purchasing Buspar without a script|buy Buspar australia|purchase Buspar visa without prescription|online purchase Buspar|buy Buspar no perscription cod|buy Buspar drugs|buy Buspar with visa|buy Buspar without rx needed|buy Buspar without prescription|buy Buspar no prescription low cost|purchase purchase Buspar no prescription cheap buy cheap Nolvadex cod buy Nolvadex infertility in internet visa at Wisconsin Ontario omicrosoft office 2003 megaupload online purchase Lasix Buy genuine accutane online buy nolvadex amex online where to buy synthroid in germany where to buy synthroid pills cheap discount Nolvadex overnight Accutane 20mg mexico order Lasix usa Lasix overnight delivery fed ex buy zithromax overnight purchase online prescription zithromax without buy Nolvadex cheap cheapest Nolvadex available online buy Nolvadex without rx from us pharmacy buy Nolvadex without a prescription overnight delivery buy 20mg Nolvadex free shipping buy Nolvadex no prescription order zithromax overnight delivery buy zithromax 100 mg visa Valtrex without doctor prescription buying zithromax over the counter order zithromax with no prescription order zithromax 250mg mastercard order zithromax 250 mg visa order zithromax 500mg amex buy mail order Orlistat buy Valtrex online now Orlistat tablets purchase cheap Maxalt onlinebuy generic Maxalt pills free fedex delivery Buspar buy cheap Finpecia under without rx purchase online finpecia without rx finpecia fedex no prescription buy line finpecia fedex Valtrex overnight without a rx Buspar u.p.s shipping cod order cheap overnight Buspar free fedex delivery prednisone prednisone no script fedex buy valtrex cheap without prescription generic Valtrex fedex Online overnight shipping Valtrex purchase Zithromax without purchase Zithromax no scams Arimidex delivered overnight order cheap overnight Arimidex purchase Cytotec over the counter fedex buy Cytotec online overnight adobe financial results microsoft office professional 2007 upgrade download microsoft office professional 2007 cheap Buspar by money order how to buy Valtrex without a prescription cheap valtrex uk buy Flomax in the uk purchase Proscar usa cod adobe lm service adobe after effects simple creativity latest adobe flash download buy Crestor amex measurement software Photoshop For Sale buy discount Tamsulosin line Autocad 2010 Review download adobe premiere complete removal of office 2003 adobe indesign cs2 photoshop lightroom 3 cheap where can i buy herbal Crestor where to buy Crestor buy Crestor online cod Buy Fincar online 5 mg mastercard cheapest price for microsoft office vio software discount coupon purchase Orlistat amex online without prescription buy maxalt online without a prescription adobe photoshop 6 cd key Cheap Software Buy Downloads For Photoshop flash catalyst sql ms office 2010 enterprise windows 7 upgrade oem Windows Server 2003 Standard Edition Downloads For Windows 7 Ultimate buy Valtrex no prescriptions application free download office microcoft2007 buy Crestor drugs Valtrex no prescription purchase Valtrex amex online without prescription Xenical Orlistat Flomax buy on line boilsoft viseo create new instrument logic studio 9 cheap purchase finpecia Flomax best buy buy cheap oem software formica countertop cyberlink power dvd 9 download buy Prednisone no prescriptions cheap indesign cs android acdsee buy Flomax australia generic Valtrex online lightroom license .txt download de driver para corel windvd buy microsoft office online cheap generic Valtrex online buy Flomax online no prescription buy pharmacy Flomax waterview cheap Valtrex by money order ifinance price price of valtrex buy valtrex doctor prescription buy generic Crestor order generic Tamsulosin imtoo dvd ripper serial look like buy Buspar without a rx cheap digital video buy Prednisone amex want to buy Buspar in malaysia Bupropion buy Bupropion buy no perscription Amitriptyline buy discount Zithromax cheapest Zithromax available online how to order Buspar online without a rx purchase prednisone cod next day delivery where can i purchase prednisone online prednisone online cash on delivery microsoft office 2010 3 user license cheap mac desktops no prescription Orlistat cod delivery Work Order Tracking System Acrobat 6.0 Professional Oem Version Windows 7 buy Valtrex where order Orlistat no rx cheap proffes Microsoft Windows Xp Purchase buy Valtrex legally Windows Xp Server buy cheap online pharmacy Buspar buy Prednisone online now generic Zithromax usa accutane 40 mg delivered overnight buy accutane 40 mg with no prescription media 8 oline cheap cs software Discount Microsoft WindowsLightroom 2 Windows 7Ms Office StandardPhotoshop Cs5 UpgradeComputer Monitors For SaleWindows Xp InstallSuite Microsoft OfficeAutocad Version 2007Adobe Acrobat 9.0 Standard DownloadIe8 Download For Windows 7Adobe Paint ShopMicrosoft Service Pack 2Free Download Adobe AcrobatStudent And Teacher EditionManage ImageAdobe Acrobat 7 Pro DownloadVista Home Premium To Windows 7 UltimateWindows 7 Home Premium Upgrade OemAdobe Creative Suite 5 Master Collection Student And Teacher EditionBuy Adobe Photoshop Lightroom 3Ms Office 2010 Home And StudentCompare Photo SoftwareMicrosoft Office Word Viewer 2010Windows 7 Upgrade Student Discount ProfessionalWindows 7 Updates DownloadCreative Suite WebAdobe Reader VistaMicrosoft Windows 7 Home Premium Upgrade 64 BitPhotoshop 2Ie8 Download For Windows 7Photoshop 2009Suite Microsoft OfficeMicrosoft Office 2007 VersionUpgrade Windows Vista To 7Autocad Lt 2010Autocad 2010 Best PriceDownload Acrobat Reader 8 buy Flomax online us pharmacy cheapest Buspar available online where can i purchase Buspar without a prescription sony oem software Valtrex from india Prednisone prescription order Buspar shipped by cash on delivery buy Valtrex with no prescription prezzo Valtrex buy Valtrex shipped cod Proscar no prescription overnight Proscar overnight no consult where to purchase cheap Cytotec no rx Cytotec to buy is it legal to buy Cytotec online in australia buy Cytotec cheapest buy finpecia without prescription finpecia buy cod want to buy finpecia in malaysia buy finpecia with mastercard Buy Finpecia 1 mg online microsoft onenote and educator discount window mirror film charset windows 1252 reinstal windows finpecia overdose excel new window windows for loop microsoft office 2008 for mac home student cheap collection software virtual dj software web design software mac cheap or discount photoshop software load windows xp buy Orlistat legally Rosuvastatin generic order buspar pharmacy buy Flomax in mo dreamweaver cs4 windows mobile opera adobe photoshop price epson creativity suite
Go to Top