Java Reference
In-Depth Information
the combined system, though, the deployment story is really simple, as the sidebar demon-
strates.
Groovy and Java together at runtime
At runtime , compiled Groovy and compiled Java both result in bytecodes for the JVM. To
execute code that combines them, all that's necessary is to add a single JAR file to the sys-
tem. Compiling and testing your code requires the Groovy compiler and libraries, but at
runtime all you need is one JAR.
That JAR comes with your Groovy distribution in the embeddable subdirectory. Suppose,
for example, your Groovy installation is version 2.1.5. Then on your disk in the Groovy
installation directory you have the structure shown in the following figure, and the JAR file
you need is groovy-all-2.1.5.jar.
Add the groovy-all JAR to your system, and you can run it with the java command.
Inthe rest ofthe text, I'll refer to this JAR file as the “groovy-all” JAR. Ifthis JAR is added
to your classpath you can execute combined Groovy and Java applications with the stand-
ard java command. If you add a Groovy module to a web application, add the groovy-all
JAR to the WEB-INF//lib directory and everything will work normally.
Here's a minimal demonstration just to prove the point. Consider the “Hello, World!” ap-
plication written in Groovy, which, unlike in Java, is a one-liner:
println 'Hello, Groovy!'
Search WWH ::




Custom Search