I am trying to write some code in ruby (using jruby) to be compiled to java bytecode with jrubyc and deployed to a remote machine where it will be run on the JVM (no ruby available there).

Everything works fine as long as I am happy to stick with the standard jruby library. As explained on the jruby website, I simply copy the jruby-complete.jar library to the remote machine and include it in the classpath at runtime. I fire my compiled script and it works: cool!

The problems start when I need some other libraries (typically rubygems) to run my script.
I am aware of cool stuff like rawr, -which I successfully tested- to put together all you need in a single package. However that is not the solution I am looking for: I will have many small scripts to run independently and I don't want each of them to grow to at least 10 MB just because I insanely include the jruby-complete.jar in each of them.

What I would like is to compile a .jar for each of the libraries that I will need to use, put all of them in a common folder on the remote machine and include them at runtime in the classpath when I run my compiled jruby scripts on the JVM.
This said, I tried to follow the instructions here: http://blog.nicksieger.com/articles/2009/01/10/jruby-1-1-6-gems-in-a-jar
I tried exactly the example shown there, with the "chronic" gem. Going step by step:

  1. Install the gem locally: java -jar jruby-complete-1.1.6.jar -S gem install -i ./chronic chronic --no-rdoc --no-ri
  2. Package it into a jar: jar cf chronic.jar -C chronic .
  3. Write a two lines test script, saving it as testt.rb:

    require 'chronic'
    Chronic.parse('tomorrow')

  4. Compile with: jrubyc testt.rb

  5. Run the resulting java class testt.class with the following (having both jruby
Edit
Report