Chris Finch wrote:
Let me know if you'd like to hear more...
A reply from Mr. JRuby himself - what a forum!
Yes please, if you'd be so kind - any tutorial, instructions, further information?
There's no official tutorial or walkthrough (though there should be). Of course you can always just distribute JRuby, but it sounds like you want a single package (i.e. a single file?), so basically, there's two options:
1. Add your code at the root of one of the "complete" JRuby JAR files, which include all of the Ruby stdlib as well as the full JRuby implementation. Once it's in the file (which is mostly a standard ZIP file) you can do someting like the following:
<cli>
java -jar my-jruby-complete.jar -e "load 'myscript.rb'"
</cli>
2. You can also modify the JAR by including your code and a "main" Java class that knows how to run it. Basically, this would involve a simple main method something like the following:
<java>
package org.something;
public class MyMain {
public static void main(String args) {
org.jruby.Main.main(new String {"myscript.rb"});
}
}
</java>
And then an entry in the manifest file in the JAR (under META-INF/MANIFEST.MF) like so:
<manifest>
Main-Class: org.someting.MyMain
</manifest>
With this, you could just run the jar directly:
<cli>
java -jar my-special-jruby.jar
</cli>
The bottom line in both cases is that no rebuild of JRuby is necessary. It's one-stop-shopping for redistributable Ruby applications!
- Charlie