Installing Groovy-Grails on Ubuntu


Now a days I am working with Groovy/Grails. This is really awesome language. Installing this in Ubuntu is very easy and this can be done very fast and in easy way. So how I installed Groovy/Grails up and running.

First install openjdk and groovy. Since in ubuntu these 2 packages are already available. So install it via apt-get.

sudo apt-get install openjdk-6-jdk
sudo apt-get install groovy

java -version
java version "1.6.0_18"
OpenJDK Runtime Environment (IcedTea6 1.8) (6b18-1.8-0ubuntu1)
OpenJDK Client VM (build 14.0-b16, mixed mode, sharing)

groovyConsole

Now for installing Grails. We need to install via binary zip file.
Get the latest Binary Zip file and save to some of your location.
Unzip the folder and move to /usr/share/grails/
I just moved grails to /usr/share/ because ubuntu install Groovy at /usr/share/groovy so making the similarity.

Now Set the JAVA_HOME and GRAILS_HOME path for your profile. Since we are installing Grails via zip binary so we need to tell the system that where is Grails and where is JAVA.

Open ~/.profiles file and add these lines at the top.

JAVA_HOME=/usr/lib/jvm/java-6-openjdk
GRAILS_HOME=/usr/share/grails
PATH=$PATH:/usr/share/grails/bin
export JAVA_HOME PATH
export GRAILS_HOME PATH

And logout and login again and do

printenv

This will show you that Grails path is set for our profile.

Now just say

ganu@ganu:/usr/share/grails$ grails
Welcome to Grails 1.3.6 - http://grails.org/
Licensed under Apache Standard License 2.0
Grails home is set to: /usr/share/grails

Use ‘grails help’ for more info or ‘grails interactive’ to enter interactive mode

DONE !! WOW.

How to check where Groovy-Grails combination is working.

Go to your development Grails folder.

ganu@ganu:~/grails$ grails create-app wpdemo
Welcome to Grails 1.3.6 - http://grails.org/
Licensed under Apache Standard License 2.0
Grails home is set to: /usr/share/grails

Base Directory: /home/ganu/grails
Resolving dependencies...
Dependencies resolved in 2867ms.
Running script /usr/share/grails/scripts/CreateApp_.groovy
Environment set to development
...........
Executing tomcat-1.3.6 plugin post-install script ...
Plugin tomcat-1.3.6 installed
Plugin provides the following new scripts:
------------------------------------------
grails tomcat
Created Grails Application at /home/ganu/grails/wpdemo
ganu@ganu:~/grails$ cd wpdemo/
ganu@ganu:~/grails/wpdemo$ ll
total 28
-rw-r--r--  1 ganu ganu  178 2011-02-13 03:43 application.properties
drwxr-xr-x 10 ganu ganu 4096 2010-12-15 08:22 grails-app
drwxr-xr-x  2 ganu ganu 4096 2011-02-13 03:43 lib
drwxr-xr-x  2 ganu ganu 4096 2011-02-13 03:43 scripts
drwxr-xr-x  4 ganu ganu 4096 2011-02-13 03:43 src
drwxr-xr-x  4 ganu ganu 4096 2011-02-13 03:43 test
drwxr-xr-x  7 ganu ganu 4096 2010-12-15 08:22 web-app
ganu@ganu:~/grails/wpdemo$ grails run-app
Welcome to Grails 1.3.6 - http://grails.org/
Licensed under Apache Standard License 2.0
Grails home is set to: /usr/share/grails

Base Directory: /home/ganu/grails/wpdemo
Resolving dependencies...
Dependencies resolved in 2986ms.
Running script /usr/share/grails/scripts/RunApp.groovy
Environment set to development
...........
Running Grails application..
Server running. Browse to http://localhost:8080/wpdemo
Groovy/Grails SEtup
Groovy/Grails SEtup

Happy Programming.

About these ads

6 thoughts on “Installing Groovy-Grails on Ubuntu

  1. Nice article, having only briefly played with grails on windows I hadn’t tried until today in ubuntu. Think I’ll spend some time out of my php comfort zone and play again with this syntax beautiful language. Hope to see more grails stuff online in the future, adoption for this seems low around me.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s