JSR-223 is designed to allow Java access to many scripting languages. This means that it also provides hooks for Groovy to those other languages.
JSR-223 comes with Java 6. Here is how you can use it. First we define a script manager:
The output from running these scripts is:
See also: Accessing Groovy from Java via JSR-223