Every Flavour Beans

“The time has come…to talk of many [technologies].” –Lewis Carroll(’The Walrus and the Carpenter’)
Development Tools. Web Frameworks. GNU/Linux. Nokia N800. Video Encoding.

July 14, 2008

Installing Grails in Ubuntu GNU/Linux Using Package Manager

Filed under: GNU/Linux, Groovy/Grails, Ubuntu — tabrez @ 3:21 pm

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.


If you want to receive future posts by email, enter your email address here:

Related Posts:

  • Setting Up Development Environment For Grails on GNU/Linux
  • Creating “Hello World” Web Application Using the Grails Framework
  • Setting Up Development Environment For Grails on Windows Vista/XP
  • Installing Complete LAMP Stack on Ubuntu 6.10(Edgy Eft)
  • Setting Up Rails Development Environment on Ubuntu GNU/Linux
  • Installing C#/Mono(.NET)/MonoDevelop/XSP in Ubuntu Gutsy Gibbon(7.10)
  • ‘wget -c’ Bug in Download Script Generated by Synaptic in Ubuntu 7.10(Feisty Fawn)

  • Readers who viewed this page, also viewed:


    July 10, 2008

    Setting Up Development Environment For Grails on GNU/Linux

    Filed under: GNU/Linux, Groovy/Grails, Java, Web — tabrez @ 2:32 pm

    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.


    If you want to receive future posts by email, enter your email address here:

    Related Posts:

  • Creating “Hello World” Web Application Using the Grails Framework
  • Installing Grails in Ubuntu GNU/Linux Using Package Manager
  • Setting Up Development Environment For Grails on Windows Vista/XP
  • Setting Up Rails Development Environment on Ubuntu GNU/Linux
  • C++ Development Environment on Windows using Eclipse Ganymede and Nuwen MinGW
  • Wascana is Eclipse Based Standalone C++ IDE for MS Windows
  • Setting Up C++ Development Environment on Windows with EasyEclipse and MinGW

  • Readers who viewed this page, also viewed:


    June 15, 2008

    Creating “Hello World” Web Application Using the Grails Framework

    Filed under: Groovy/Grails, Web — tabrez @ 4:04 pm

    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)


    If you want to receive future posts by email, enter your email address here:

    Related Posts:

  • Setting Up Development Environment For Grails on Windows Vista/XP
  • Setting Up Development Environment For Grails on GNU/Linux
  • Installing Grails in Ubuntu GNU/Linux Using Package Manager
  • “Hello, World” Web Application using Struts 2 in IntelliJ IDEA 8.0 M1
  • Should I Be Developing Ajax Applications using Google Web Toolkit(GWT)?
  • A Case Against Ajax Web Development Model
  • Struts 2 Plugin for NetBeans IDE - nbstruts2support

  • Readers who viewed this page, also viewed:


    Setting Up Development Environment For Grails on Windows Vista/XP

    Filed under: Groovy/Grails, Web — tabrez @ 3:49 pm

    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.


    If you want to receive future posts by email, enter your email address here:

    Related Posts:

  • Creating “Hello World” Web Application Using the Grails Framework
  • Setting Up Development Environment For Grails on GNU/Linux
  • Installing Grails in Ubuntu GNU/Linux Using Package Manager
  • Setting Up Rails Development Environment on Ubuntu GNU/Linux
  • C++ Development Environment on Windows using Eclipse Ganymede and Nuwen MinGW
  • Wascana is Eclipse Based Standalone C++ IDE for MS Windows
  • Setting Up C++ Development Environment on Windows with EasyEclipse and MinGW

  • Readers who viewed this page, also viewed:



    Copyright (c) 2006, 2007 Tabrez Iqbal.
    Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. Verbatim copying and distribution of this entire article is permitted in any medium without royalty provided this notice is preserved. A copy of the license is included in the section entitled "GNU Free Documentation License".


    Powered by WordPress
    This website is hosted by Dreamhost