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 Windows


In this recipe, we will provide instructions on installing the Groovy distribution on the Windows operating system.

Getting ready

The requirement for installing Groovy 2.0 is JDK 1.5 and higher. We assume that you have JDK installed and know how to use Java. In case you use JDK 7 or later, then you can take advantage of the dynamic language optimization present in that version. For instance, the invokedynamic bytecode instruction (see the Running Groovy with invokedynamic support recipe).

To install Groovy on Windows, you need to download the ZIP distribution from http://groovy.codehaus.org/Download.

The latest major version at the time of writing is 2.1.6. The latest minor version is 2.0.8. Since v2.0, Groovy has changed the release version numbering, so the next major version of Groovy will be 3.0 and the next minor versions will have the second digit increased (2.1, 2.2, 2.3, and so on).

Alternatively, you can build Groovy from the source distribution which is described in the Building Groovy from source recipe.

How to do it…

After downloading the zipped distribution, you need to unzip the archive to a directory of your choice and carry out the following steps to install Groovy on Windows:

  1. For simplicity, we will assume that the directory is C:\Applications\groovy-2.0. The contents of the directory should look as shown in the following screenshot:

  2. In order to have the groovy command available on your command line, you need to add it to your system's path by setting the environment variable named PATH. We also advise you to create a GROOVY_HOME variable for simpler reference.

  3. To access the Windows environment variables, you need to press the Windows + Break key combination. On Windows Vista, Windows 7, or later, it will open the Control Panel page for system settings.

  4. Click on Advanced system settings to open the System Properties window.

  5. Then you need to click on the Environment Variables... button to finally get to the list of the system variables.

  6. Click on the New... button and add the GROOVY_HOME variable pointing to your Groovy installation path:

  7. Then find the Path variable in the list of system variables and append or insert the %GROOVY_HOME%\bin; string to it:

  8. You can now fire the Windows command line and verify that Groovy is installed correctly by issuing the groovy --version command:

If you get the output displayed as in the previous screenshot, your Groovy installation is complete.

There's more...

As an alternative to the zipped archive, Windows users can also download a one-click installer (you can find the link on the same download page under the Download Windows-Installer link). Execute the installer and follow the instructions to get a fully functional Groovy installation.

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