APPENDIX B: Introduction to Groovy 401
Listing B-3. Groovy Script for “Hello World”
println "Hello World!"
You can run Groovy scripts and classes through the command line, GroovyShell, or GroovyConsole.
GroovyShell
GroovyShell is an interactive command-line application (shell) that allows you to create, run, save,
and load Groovy scripts and classes. To start GroovyShell, run groovysh. Figure B-1 illustrates using
GroovyShell to execute a simple script.
Figure B-1. Using GroovyShell
As you can see, the script prints vishal. Then you see ===> null. As a matter of convention,
Groovy always returns the results of methods. In this case, there is no result, so null is returned.
GroovyShell contains a built-in help facility that you can use to learn more about the shell. To access
it, type help at the prompt. Figure B-2 shows the help listing.