Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Groovy 2 Cookbook

You're reading from   Groovy 2 Cookbook Java and Groovy go together like ham and eggs, and this book is a great opportunity to learn how to exploit Groovy 2 to the full. Packed with recipes, both intermediate and advanced, it's a great way to speed up and modernize your programming.

Arrow left icon
Product type Paperback
Published in Oct 2013
Publisher Packt
ISBN-13 9781849519366
Length 394 pages
Edition 1st Edition
Languages
Arrow right icon
Authors (2):
Arrow left icon
Luciano Fiandesio Luciano Fiandesio
Author Profile Icon Luciano Fiandesio
Luciano Fiandesio
Andrey Adamovich Andrey Adamovich
Author Profile Icon Andrey Adamovich
Andrey Adamovich
Arrow right icon
View More author details
Toc

Table of Contents (17) Chapters Close

Groovy 2 Cookbook
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
1. Getting Started with Groovy 2. Using Groovy Ecosystem FREE CHAPTER 3. Using Groovy Language Features 4. Working with Files in Groovy 5. Working with XML in Groovy 6. Working with JSON in Groovy 7. Working with Databases in Groovy 8. Working with Web Services in Groovy 9. Metaprogramming and DSLs in Groovy 10. Concurrent Programming in Groovy Index

Installing Groovy on Linux and OS X


This recipe gives you instructions for installing Groovy on any Linux distribution and Mac OS X.

How to do it...

As a starter, download the Groovy 2.0 binaries as described in the Installing Groovy on Windows recipe and perform the following steps to install Groovy on Linux and OS X:

  1. Create a new folder for the Groovy distribution:

    sudo mkdir /usr/share/groovy
    
  2. Move the unzipped Groovy folder into /usr/share/groovy and create a symlink to the folder, without using the version number:

    sudo mv groovy-2.1.6 /usr/share/groovy/
    sudo ln -s /usr/share/groovy/groovy-2.1.6 current
    
  3. Finally, add Groovy to the path by editing your ~/.profile (or ~/.bash_profile) file. You can use vi or an editor of your choice:

    export GROOVY_HOME=/usr/share/groovy/current
    export PATH=$GROOVY_HOME/bin:$PATH
    
  4. Your JAVA_HOME variable should be set as well. On OS X, the recommended way to set the variable is as follows:

    export JAVA_HOME=$(/usr/libexec/java_home)
    
  5. Reload your ~/.profile file by typing:

    source `~/.profile`
    
  6. To test if your installation is successful, type:

    groovy -version
    

The output should display the installed Groovy version and the JDK in use.

Tip

Downloading the example code

You can download the example code files for all Packt books you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

How it works...

Using the symbolic link called current, which we created in step 2, makes it very easy to upgrade to a newer version of Groovy by changing the folder to which the symbolic link points to.

There's more...

Most *nix-based operating systems (such as Linux or Mac OS X) have package manager systems that allow you to install Groovy by simply typing a command in the terminal.

In Ubuntu, Groovy can be installed by simply typing:

sudo apt-get install groovy

The version installed by the Ubuntu package manager is quite old (1.7.10), so you may want to install Groovy manually as described in this recipe.

In OS X, you can use Homebrew as follows:

brew install groovy

If you are happy with running a stable version of Groovy, but possibly not the most recent one, a package manager is the recommended way to get Groovy quickly and easily. If you want to install a beta version of Groovy or a version that is not yet available on the package manager system used by your OS, install the binaries from the website.

See also

  • Managing multiple Groovy inst allations on Linux

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime