...
To make this example work, if you're running Groovy 1.5.x, add groovy-engine.jar from https://scripting.dev.java.net/ to your CLASSPATH and run this program using Java 6. But since Groovy 1.6, Groovy already contains the groovy scripting engine compliant with JSR-223.
This next example illustrates calling an invokable function:
...