Running Groovy
Now that you have Groovy installed, let's introduce some of the tools that come with the Groovy package. Groovy can be compiled into a Java class file and deployed as part of an application, the same as for any other Java class file. In addition to this, Groovy has several tools that allow us to execute a Groovy program as a script without the need to package it into a Java application.
There are three commands that we can use to launch a script. In the following sections, we will demonstrate the different methods of running Groovy scripts. As we progress through the book, you can use these methods to execute the Groovy scripts that we will describe.
The Groovy script engine – groovy
Let's start by writing a Groovy version of the ubiquitous
Hello World program. We can start by creating a file called Hello.groovy
, which contains the following code:
public class HelloGroovy { public static void main(String [] args) { System.out.println("Hello, World...