Groovy has been designed to be very lightweight and easy to embed into any Java application system.
You can use
Evaluate scripts or expressions using the shell
You can evaluate any expression or script in Groovy using the
The GroovyShell allows you to pass in and out variables via the
Dynamically loading and running Groovy code inside Java
You can use the
The following Java code shows an example...
If you have an interface you wish to use which you implement in the Groovy script you can use it as follows
This works fine if the Groovy class implements the inferface MyInterface. myObject can from then on be used as every other Java object implementing MyInterface.
As well as Java 1.4 and the Groovy jar we also depend at runtime on the ASM library constituted of four jars (asm-1.5.2.jar, asm-util-1.5.2.jar, asm-attrs-1.5.2.jar and asm-analysis-1.5.2). That's it. So just add these 5 jars to your classpath and away you go, you can happily embed Groovy into your application.
Alternatively, instead of several jars, you can use groovy-all-1.0-beta-x.jar included in the GROOVY_HOME/embeddable directory of your distribution: this jar contains both Groovy and ASM combined in a single and convenient archive.