I’ve found an example for running Groovy scripts on systems that do not have Groovy installed using the groovy-all jar file. I attempted the following:
java -cp src:.:lib/* -jar lib/groovy-all-2.0.1.jar src/com/example/MyScript.groovy
The trouble is my script depends on jars in the lib directory plus two other Groovy script files located in src/com/examples. When I run this, it complains about the import statements for all of them. I can run it on a system that has Groovy installed fine by using the following:
CLASSPATH="src:.:lib/*" groovy src/com/example/MyScript.groovy
How do I run Groovy scripts this way, using the groovy-all jar, as well as give it a classpath?
You can’t combine both
-jarand-cpin ajavacommand, so you need to name the main class explicitly. Looking at the manifest of thegroovy-allJAR, the main class name isgroovy.ui.GroovyMain, so you need(if groovy-all were not already covered by
lib/*you would need to add that to the-cpas well).