10.1 The Melting Pot of Java and Groovy
In our applications, we can implement a certain functionality in a Java class, a Groovy class, or a Groovy script. Then we can call this functionality from within Java classes, Groovy classes, or Groovy scripts. Figure 9, Ways to mix Java classes, Groovy classes, and scripts shows the various options for mixing Java classes, Groovy classes, and Groovy scripts.
To use Groovy classes from Groovy code, we don’t have to do anything. It just works. We simply make sure the classes we depend on are in the classpath, either as source or as bytecode. To pull a Groovy script into our Groovy code, we can use GroovyShell. To use it from within our Java classes, we can use the ScriptEngine API provided by JSR ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access