I’ve packaged my application in a Jar with all dependencies accessible
via the manifest, but to package the dependencies into a single jar, I
used OneJar. I understand that OneJar modifies the class loader, which
I assume is why none of the require statements work.
The application runs fine when I launch the original jar, but when I
launch the jar created with one jar, it fails at all require statements:
/some_file.rb
require ‘java’
include Java
%w’rubygems drb pstore’.each do |dep|
begin
require dep
rescue LoadError => e
$stderr.puts “[ERROR] #{e.message}”
end
end
The Java code that loads this class is the following:
// note: jruby-complete is in the load path
public class RubyHelper {
public static final ScriptEngine rubyEngine;
public static final Invocable invocable;
static {
rubyEngine = new ScriptEngineManager().getEngineByName(“ruby”);
invocable = (Invocable) rubyEngine;
}
}
// another file
InputStream fis = getClass().getResourceAsStream("/some_file.rb");
RubyHelper.rubyEngine.eval(new InputStreamReader(fis));
Is there any fix for this? Anyway I can restore the class loader
without stomping on what OneJar does?