Hi JRuby users,
I’m testing/benchmarking the scripting possibilities jruby offers to
ruby programmers through the java JSR 223 interface. I’m using JRuby
1.6.6 in Ruby 1.9 mode.
Everything works fine for javascript and jruby engines, but I’m unable
to make it work for Lua, with the JNLUA library. I always get the
error:
NativeException: java.lang.UnsatisfiedLinkError: no jnlua52 in
java.library.path
(root) at jsr223.rb:12
The code I’m using is the following:
require 'java'
require 'benchmark'
require './jnlua-1.0.2.jar'
input = 10
many = 10
mgr = javax.script.ScriptEngineManager.new
js_engine = mgr.getEngineByName("javascript")
jruby_engine = mgr.getEngineByName("jruby")
lua_engine = mgr.getEngineByName("lua")
Benchmark.bm do |show|
show.report("javascript:") {
many.times do
script = " function factorial(n) {
if (n == 0) {
return 1;
}
return n * factorial(n - 1);
}
factorial(#{input})"
js_engine.eval(script)
end
}
show.report("lua :") {
many.times do
script = " function factorial(n)
if n == 0 then
return 1
else
return n * factorial(n - 1)
end
end
factorial(#{input})"
lua_engine.eval(script)
end
}
show.report("jruby: ") {
many.times do
script = " def factorial(n)
if n == 0
1
else
n * factorial(n - 1)
end
end
factorial(#{input})"
jruby_engine.eval(script)
end
}
show.report("ruby: ") {
many.times do
script = " def factorial(n)
if n == 0
1
else
n * factorial(n - 1)
end
end
factorial(#{input})"
eval(script)
end
}
end
I’ve tried launching the script in different ways, like:
jruby -J-Djava.library.path=./ jsr223.rb
… but no luck.
Any idea what happens here?
Thanks!