Should this program work?
import org.jruby.embed.ScriptingContainer;
import org.jruby.javasupport.JavaEmbedUtils;
import org.jruby.javasupport.JavaEmbedUtils.EvalUnit;
import org.jruby.runtime.builtin.IRubyObject;
public class jruby_test {
public static void main(String[] args) {
System.setProperty(“jruby.home”, “<>”);
ScriptingContainer container = new ScriptingContainer();
EvalUnit unit = container.parse(“require ‘complex’; return
Complex.new(3,4)”);
IRubyObject ret = unit.run();
Object o = JavaEmbedUtils.rubyToJava(ret);
System.out.println(o);
}
}
I get:
:1: could not coerce Complex to class java.lang.Object (TypeError) Exception in thread "main" org.jruby.embed.EvalFailedException: could not coerce Complex to class java.lang.Object at org.jruby.embed.internal.EmbedEvalUnitImpl.run(EmbedEvalUnitImpl.java:116) at jruby_test.main(jruby_test.java:11) Caused by: org.jruby.exceptions.RaiseException: could not coerce Complex to class java.lang.Object at (unknown).new(:1) at (unknown).(unknown)(:1) jruby_test.java:11 is the line IRubyObject ret = unit.run(); I guess I might have to call JavaEmbedUtils from inside the script? It would make my life easier if I could do this from the java side. Adam --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email