我正在尝试在自定义应用程序中使用 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 对象。