Search code examples
eclipsegroovyjarggts

How to create a groovy jar with eclipse/ggts?


So I create a groovy jar but I'm not able to run it.

I'm using HelloWorld.groovy as an example

class HelloWorld {

    static main(args) {
        println("Hello World");
    }
}

I save it as a jar like I would with any java file via export in eclipse/ggts:

  1. right clicking groovy file in project explorer
  2. click export
  3. select jar File
  4. specify jar file name
  5. specify HelloWorld as the main class in the Manisfest file
  6. keep all the defaults selected
  7. click finish and create the jar

Now I try to run HelloWorld.groovy via java -jar HelloWorld.jar on my command line.

I get: Exception in thread "main" java.lang.NoClassDefFoundError: groovy/lang/GroovyObject

When I export it also allows me to export .classpath into my jar. Shouldn't that include my groovy-all.jar that my GGTS is using? Am I missing something?

I've been successful with using GroovyWrapper to create groovy jars. I want to see if it's possible with just my IDE.


Solution

  • I think that in eclipse you export an executable jar and that gives the option to package the dependencies?