Welcome to Scribd. Sign in or start your free trial to enjoy unlimited e-books, audiobooks & documents.Find out more
Standard view
Full view
of .
Look up keyword or section
Like this
0 of .
Results for:
No results containing your search query
P. 1
Fluently Groovy PDF

Fluently Groovy PDF

|Views: 1,786|Likes:
Published by rajeevkri

More info:

Published by: rajeevkri on Jul 06, 2009
Copyright:Attribution Non-commercial


Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less





Fluently Groovy
Java application development using Groovy's simple syntax
Skill Level: IntroductoryAndrew Glover(aglover@stelligent.com) PresidentStelligent Incorporated26 Mar 2008This tutorial is for Java™ developers unfamiliar with Groovy, who want a quick andeasy introduction to the basics. Get started with Groovy's simplified variation of theJava syntax and learn about essential features like native collections, built-in regularexpressions, and closures. Write your first Groovy class, and then see how easily youcan use JUnit to test it. You'll walk away from this one-hour tutorial with a fullyfunctioning Groovy development environment and the skills to use it. Best of all, you'llhave learned first-hand how to use Groovy and Java code together in your everydayJava application development.
Section 1. Before you start
Learn what to expect from this tutorial and how to get the most out of it.
About this tutorial
Groovy is a lot like Java 2.0, if someone set out to completely rewrite the Javalanguage today. Rather than replacing Java, Groovy complements it, providing asimpler, slicker syntax where the type checking is done dynamically at runtime. Youcan use Groovy to write Java applications on the fly, to glue together Java modules,or even to extend existing Java applications — you can even use Groovy to unit testyour Java code. And the beauty of it is, Groovy lets you do all these things faster —
sometimes a lot faster — than you would if you were writing pure Java code.In this tutorial, you'll get to know Groovy, a dynamic language that sits ascomfortably on the Java platform as does the Java language itself.
This tutorial guides you step-by-step through the fundamental concepts of Groovy.You will learn about Groovy collections, Groovy classes, and, of course, the Groovysyntax. When you are done with this one-hour tutorial, you will understand thebenefits of using Groovy with Java (and vice versa), and you'll be set to start usingGroovy in your everyday Java development.
To get the most from this tutorial, you should be familiar with Java syntax and thebasic concepts of object-oriented development on the Java platform.
System requirements
To follow along and try out the code for this tutorial, you need a working installationof eitherSun's JDK 1.5.0_09(or later); orIBM developer kit for Java technology 1.5.0 SR3In addition, this tutorial assumes you are using theEclipse IDE. You do not need tohave Groovy installed as the tutorial walks you through the Groovy Eclipse plug-ininstallation.The recommended system configuration for this tutorial is as follows:A system supporting either the Sun JDK 1.5.0_09 (or later) or the IBMJDK 1.5.0 SR3 with at least 500 MB of main memoryAt least 20 MB of disk space to install the software components andexamples coveredThe instructions and examples in the tutorial are based on a Microsoft Windowsoperating system. All the tools covered in the tutorial also work on Linux and Unixsystems.
developerWorks® ibm.com/developerWorksFluently GroovyPage 2 of 51© Copyright IBM Corporation 1994, 2008. All rights reserved.
Section 2. About Groovy
In this section you'll learn the basics of Groovy: what it is, how it relates to the Javalanguage and the JVM, and some of the highlights of writing Groovy code.
What is Groovy?
Groovy is an alternate language for the JVM —
meaning that you can useGroovy for Java programming on the Java platform in much the same way youwould use Java code. Groovy code combines well with Java code when writing newapplications, and can also be used to extend existing ones. Groovy currently is inversion 1.5.4 and works on the Java 1.4 and Java 5 platforms, as well as Java 6.One nice thing about Groovy is that its syntax is very similar to the syntax in theJava language. While Groovy's syntax was inspired by languages like Smalltalk andRuby, you can think of it as a simpler, more expressive variation on the Javalanguage. (Ruby is different from Groovy in this regard, because its syntax is quiteunlike Java syntax.)Many Java developers take comfort in the similarity between Groovy code and Javacode. From a learning standpoint, if you know how to write Java code, you alreadykind of know Groovy. The main difference between Groovy and the Java language isthat Groovy lets you write less code (sometimes far less!) to accomplish the sametasks you might labor over in your Java code.
Groovy shortcuts
As you begin playing with Groovy, you'll find that it makes everyday programmingactivities much quicker. You'll know a lot about Groovy's syntactic shortcuts by thetime you're done with this tutorial. For now, just consider these highlights:Groovy's relaxed Java syntax allows you to drop semi-colons andmodifiers.Everything in Groovy is
unless you state otherwise.Groovy permits you to define simple scripts without having to define aformal
object.Groovy adds some magical methods and shortcuts on normal everydayJava objects to make them easier to work with.
ibm.com/developerWorks developerWorks® Fluently Groovy © Copyright IBM Corporation 1994, 2008. All rights reserved.Page 3 of 51

Activity (36)

You've already reviewed this. Edit your review.
1 hundred reads
1 thousand reads
Amit Saini liked this
Ashok Jha liked this
aimee_jc liked this
poweredgeus liked this
rameshyear2002 liked this
lsmk liked this
Nanda Kumar liked this
poweredgeus liked this

You're Reading a Free Preview

/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->