Hello world example in groovy with STS

This example shows you how you can create a Hello world Groovy example in STS.

To create Simple Hello world example, you need to create a Groovy class in your groovy project.

Below screen show you when you select new wizard in STS, select the Groovy class and click in Next Button.

Next window ask for Groovy class name, give a meaningful name click on Finish button, this will create Groovy class in your project.

Finally we will put one statement to print inside the main method of Groovy class. The HelloWorldExample.groovy class looks like below code now.

package com.java.connect.com

class HelloWorldExample {
	static void main(args){
		println "Hello groovy!"
	}
}

Now you want to run this class, just right clink on the groovy class and click on either Java Application or Groovy Script.

This will print the output on consol as below.
Hello groovy!