Is it possible to set my jruby's gem path from the ScriptEngineManager in Java? The problem is that I'm using a compressed jruby interpreter (jruby-complete.jar) and it's not possible to get this package with pre-installed gems, so what I'm trying do is running jruby from Java using the ScriptEngineManager and redirect the gem's path to the ones that I have installed on my hard drive.
Example:
public class Main {
public static void main(String[] args) {
StringBuffer jruby = null;
ScriptEngine runtime = null;
try {
runtime = new ScriptEngineManager().getEngineByName("jruby");
jruby = new StringBuffer();
jruby.append("require 'ruby/Libraries.rb'");
jruby.append("\r\n");
jruby.append("if __FILE__ == $0");
jruby.append("\r\n");
jruby.append("\tzkan = ZKANWritter.new(\"");
jruby.append("G:/path/output.xls");
jruby.append("\",\"");
jruby.append("G:/path/kanban.txt");
jruby.append("\",\"//path/LT CUU.tab\")");
jruby.append("\r\n");
jruby.append("\tzkan.write(2)");
jruby.append("\r\n");
jruby.append("end");
runtime.eval(jruby.toString());
} catch (Exception ex) {
System.out.println("Error: " + ex.getMessage());
}
}
}
Thanks in Advance
~ Eder Quiñones
I've just set the environment variables RUBYLIB & GEM_HOME programmatically from ruby:
ENV["RUBYLIB"] = "lib/libs"
ENV["GEM_HOME"] = "lib/gems"
require "library-1.rb"
...
require "library-n.rb"