On Thu, Dec 4, 2008 at 7:28 PM, Charles Oliver Nutter
<charles.nutter / sun.com> wrote:
> Joe Wfel wrote:
>>
>> What are some good ways to integrate Ruby into legacy Java applications?
>>  I realize
>> I can execute small Ruby scripts from Java like this:
>>
>>        Ruby runtime = Ruby.newInstance();
>>        runtime.evalScriptlet("puts 'Hello from Ruby'");
>>
>> However, this seems to lend itself only to small snippets of Ruby.   Often
>> I'm more likely
>> to have a larger body of Ruby code that includes many files, gem
>> dependencies, and
>> the ability to work with legacy installers.  Is there an easy way to
>> accomplish this?
>
> In general the easiest way would be to have the Ruby code implement a Java
> interface and get that instance back into Java. There's a few examples on
> wiki.jruby.org. Does that sound lke what you want?

I am just curious, but couldn't you also have a JRuby script construct
and execute
your application's mainline? Or duplicate the behaviour of the
mainline in some way.

That way you can extend Java functionality with Ruby, because you have wrapped
your entire app up in Ruby to begin with.

I have to admit that this is something I have been thinking about for
a while, if only
to gain access to easy JIRB debugging.