Monday, August 1, 2011

Build path entry is missing: GROOVY_SUPPORT

in Eclipse, after installing the Groovy Plugin, I add library "Groovy Runtime Libraries" to my project:



If I define (Window/Preferences/Java/BuildPath/Classpath variables)

GROOVY_SUPPORT=C:/Oracle4/Middleware/oepe_11gR1PS3/plugins/org.codehaus.groovy_1.8.0.xx-20110627-1300-e36/lib/groovy-all-1.8.0.jar


all is fine, and my first test of embedding Groovy into Java works:

package com.pierre.osb;

import groovy.lang.Binding;
import groovy.lang.GroovyShell; 

public class GroovyCalloutTest {
 public static void main(String[] args) {
  GroovyCalloutTest test = new GroovyCalloutTest();
  test.run();
 }

 private void run() {
  // call groovy expressions from Java code
  Binding binding = new Binding();
  binding.setVariable("foo", new Integer(2));
  GroovyShell shell = new GroovyShell(binding);

  Object value = shell.evaluate("println 'Hello World!'; x = 123; return foo * 10");
  System.out.println("value=" + value);
  
 }
}



No comments: