无法加载JRubyEngine,因为找不到org.apache.bsf.util.BSFEngineImpl

时间:2010-03-17 16:48:22

标签: java jruby jsr223

我正在尝试在自定义应用程序中使用JRuby,我似乎无法加载JRubyEngine对象。我的课程在功能上与此相似:

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

}

然而,在编辑投诉时失败了:

[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

有没有人对我从哪里获得这门课有任何见解?或者,如果有更好的方法来实例化JRubyEngine对象。

2 个答案:

答案 0 :(得分:0)

答案 1 :(得分:0)

原来我应该使用JRubyScriptEngine而不是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);
        }
    }

}