Grails Cookbook - A collection of tutorials and examples

Groovy IDE Setup

One of the biggest technical hurdle when learning a new language is setting up your programming environment. This is a short guide on how to install a Groovy IDE to your Windows Workstation with screenshots for those who are new to the Java platform. We choose Eclipse as our Groovy IDE in the tutorial below.

Install JDK

Groovy runs on top of the Java platform so the first step is to install JDK to our computer. The latest Java version as of the time of this writing is Java 8.

Go to Oracle website and download the JDK installer file. http://www.oracle.com/technetwork/java/javase/downloads/index.html


Install and follow the instructions

After installing, it is highly recommended that we update our Environment variables. Set the JAVA_HOME and point it where JDK 8 was installedl:

Install Eclipse IDE

One of the most popular Open Source IDE today for Java development is Eclipse. The steps to install Eclipse are simple. Go to the download page of the Eclipse website and download the latest EE bundle of Eclipse. As of the time of this writing, Mars is the latest version of Eclipse:
https://eclipse.org/downloads/

Download and extract to a directory on your computer:

Run eclipse and select any folder as the root folder of our projects:

Eclipse will open with no project loaded:

Install Latest Groovy
After installing Eclipse, we can now install a plugin to support the Groovy language. As of the time of this writing, the latest is version 2.4. To install the Groovy 2.4 compiler to eclipse, go to Install New Software:

And use the update site: http://dist.springsource.org/snapshot/GRECLIPSE/e4.5/

And install Groovy 2.4 feature and the required components:

Now that we installed Eclipse and the required plugin, we can start to create our project. Just go to file, and then new, and then choose Groovy Project, to create a new Groovy project in Eclipse:

Give your project a name and then click finish:

A blank project will be created for you:

To create a new Groovy class for your Eclipse project, right click on the src and then new, and then choose Groovy Class:

Give your Groovy class a name:

And then enter some code. I use this code for this example:
class FirstGroovyClass {
	public static main(String[] args) {
		println "Hello World"
	}
}

To run the newly created class, right click on it, and then run as, and choose Groovy console:

The output is shown on the Console section of Eclipse:

Notes

It is shown how to setup our Windows environment for Groovy development using Eclipse. It is also shown how to create a project and run our first Groovy program. We can use our setup now for exploring the goodness of the Groovy language.
List of Tutorials for Beginners