Here we need to use the Bean Scripting Framework (BSF) since Java 5 doesn't have the built-in scripting support that Java 6 has. I will also use 2 helper classes (JRubyHelper.java and BSFHelper.java) provided by ociweb.com. For brevity I will leave out the source of the helper classes and concentrate on the actual code to make a call to a Ruby script from Java:

Line 31: initializes an empty ArrayList that will be passed into the Ruby script.
Line 32: declares (or registers) the books by name which can then be referenced in the Ruby script.
Line 33: actually executes the Ruby script.
Lines 36-40: just looping over the books and printing the titles.

Here I've created an arjava directory under the Rails plugins directory: