0

I'm trying to use JRuby in a custom application, and I don't seem to be able to load the JRubyEngine object. My class looks like functionally similar to this:

public class ScriptEngine {

    private static ScriptEngine engine = new JRubyEngine();

    public void run(final String script, final Map<String,Object> input) {
        final Bindings context = engine.createBindings();

        context.putAll(input);

        try {
            engine.eval(script,context);
        } catch (ScriptException e) {
            log.error("Failed to execute script: "+getScript(),e);
        }
    }

}

However this fails at compilation with the complaint:

[javac] Compiling 486 source files to /workspace/myProject/build/src
[javac] /workspace/myProject/src/net/ceilingfish/ScriptEngine.java:31: cannot access org.apache.bsf.util.BSFEngineImpl
[javac] class file for org.apache.bsf.util.BSFEngineImpl not found
[javac]     private static ScriptEngine engine = new JRubyEngine();
[javac]                                          ^
[javac] 1 error

Does anyone have any insights on where I can get this class from? Or if there is a better way to be instantiating a JRubyEngine object.

Ceilingfish
  • 5,131
  • 3
  • 41
  • 68

2 Answers2

0

You can download Apache BSF from http://jakarta.apache.org/site/downloads/downloads_bsf.cgi

matt b
  • 132,562
  • 64
  • 267
  • 334
0

Turns out I should have been using JRubyScriptEngine not JRubyEngine. e.g.

import com.sun.script.jruby.JRubyScriptEngine;
    .... other imports

public class ScriptEngine {

    private static ScriptEngine engine = new JRubyScriptEngine();

    public void run(final String script, final Map<String,Object> input) {
        final Bindings context = engine.createBindings();

        context.putAll(input);

        try {
            engine.eval(script,context);
        } catch (ScriptException e) {
            log.error("Failed to execute script: "+getScript(),e);
        }
    }

}
Ceilingfish
  • 5,131
  • 3
  • 41
  • 68