1、groovy下载地址: :
http://groovy.codehaus.org/Download?nc
2、Eclipse中集成Groovy编译插件:
http://dist.codehaus.org/groovy/distributions/update/
3、例子:
package groovy;
public interface ITest {
public void talk();
}
package groovy;
import java.io.File;
import groovy.lang.GroovyClassLoader;
public class TestGroovy {
/**
* @param args
*/
public static void main(String[] args) {
ClassLoader cl = new TestGroovy().getClass().getClassLoader();
GroovyClassLoader loader = new GroovyClassLoader(cl);
try {
Class groovyClass = loader.parseClass(new File("src/groovy/Test.groovy"));
ITest test = (ITest)groovyClass.newInstance();
test.talk();
} catch (Exception e) {
e.printstacktrace();
}
}
}
Test.groovy
/**
*
*/
package groovy;
/**
* @author zhangchao02
*
*/
public class Test implements ITest {
/* (non-Javadoc)
* @see groovy.ITest#talk()
*/
@Override
public void talk() {
System.out.println("ok test groovy");
}
}