stdlib
directory which is in the same directory as the jruby.jar
libray. For example:jruby.jar stdlib ---- bigdecimal ---- cgi -----...However, it is possible to use another directory by using the static method RubyScriptWrapper.setStdLibPath(File).
import
declaration does not work anymore, you must now use java_import
instead.import 'java.util.List' def execute(list) return list.size() endYou must use instead:
java_import 'java.util.List' def execute(list) return list.size() end
public interface Script { public int execute(); }And the following
support.rb
Ruby script:def give() return 10; endAnd finally the Ruby script implementing the interface:
load 'support.rb' def execute() return give() endExecuting this script will return 10.
Script
interface:public interface Script { public int execute(); }To create the wrapper, you must use a RubyScriptWrapper:
ScriptWrapper<Script> wrapper = new RubyScriptWrapper<Script>(){ }; Script script = wrapper.getScript(); File file = new File(<our script file>); wrapper.installScript(file); int value = script.execute();You can use for example the following script:
def execute() return 10; end
Copyright 2019-2020 Herve Girod. All Rights Reserved. Documentation and source under the BSD licence