package groovytest; import groovy.lang.Binding; import groovy.lang.GroovyShell; import groovy.lang.Script; import java.util.HashMap; public class GroovyJavaInterOpTest { final static int NUMRUNNERS = 2; static String scrStr1 = "def foo(x)\n" + "{\n" + " println x;\n" + "}\n" + "foo(y)\n" + ""; public static void main(String[] args) throws Exception { GroovyShell gr = new GroovyShell(); Script sc = gr.parse(scrStr1); HashMap map = new HashMap(); map.put("y", new Integer(4)); sc.setBinding(new Binding(map)); sc.run(); } }