Skip to content

Instantly share code, notes, and snippets.

@davisinfo
davisinfo / rjb_loader.rb
Created April 10, 2019 10:00
Using java libraries to fill a XLS file from Ruby - works both with MRI and jruby
if !(RUBY_PLATFORM =~ /java/)
require 'rjb-loader'
RjbLoader.before_load do |config|
# This code changes the JVM classpath, so it has to run BEFORE loading Rjb.
Dir[File.join(Rails.root , '/resources/*.jar')].each do |path|
config.classpath << File::PATH_SEPARATOR + File.expand_path(path)
config.java_options = ['-Xms128M', '-Xmx256M']
end
end