10.2 Running Groovy
We have two options for running Groovy code. First, we can use the
groovy command on our source code. Then Groovy automatically compiles code in memory
and executes it. We don’t have to take an explicit step to compile it.
Second, if we want to take a more traditional Javalike approach of explicitly compiling code to create
bytecode—the .class file—we can do that using the groovyc
compiler. To execute the bytecode, we’ll use the java command just like we would to execute our compiled Java code. The only difference is that we need to have the
groovy-all-2.1.0.jar file in the classpath. Remember to add a dot (.) to the classpath so java can find your classes in the current directory. This Java archive (JAR) ...
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