Geo
Geo

Reputation: 96767

Groovy rootLoader is null

When running a groovy script from Eclipse, the following line:


def rootLoader = this.class.getClassLoader().getRootLoader()

is null. When I run the script directly from command line, this is not null. How can I find out why this happens?

Upvotes: 1

Views: 2107

Answers (1)

kaorukobo
kaorukobo

Reputation: 2383

It depends on how you to start groovy script.

If you run (without 'groovy' command):

java -cp lib/groovy-all-1.7.5.jar groovy.ui.GroovyMain YourGroovyScript.groovy

Script is run, but rootLoader is null.

If you want to use rootLoader, run script with this command line:

java -cp lib/groovy-all-1.7.5.jar org.codehaus.groovy.tools.GroovyStarter --classpath lib/groovy-all-1.7.5.jar --main groovy.ui.GroovyMain YourGroovyScript.groovy

Upvotes: 1

Related Questions