Posted on

creating jar files with groovy

So I saw recently that its quite simple to compile down a groovy script into a .jar file.
http://groovy.codehaus.org/WrappingGroovyScript

I guess that hello world .class file looked something like this in groovy

class HelloWorld {
   static main( args ){
      println "Hello World!"
   }
}

So does that mean I can write code as groovy, and then import the jar as a dependency into a Java project?

I am assuming the answer is yes, because groovy compiles down to the same byte code as Java.

Now the question is, is it better to deliver a stand alone .jar file to my co-worker to execute on the command line, or import into his project as a dependency and call methods on it?

I see finally Java has copied a feature of .NET. All .NET languages compile down to the same byte code.