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)


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();;

 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: