Calling JRuby from Ruby

Whats the best way of running a JRuby script from Ruby?

I know you can do this : `jruby script.rb`, but that won't allow passing
of parameters from ruby to jruby.

You could pass parameters by passing the Object.inspect string and then
doing an eval:

`jruby script/rb #{object.inspect}`
.

I suppose you could serialize your objects/parameters and pass it though
that way.

Any decent ideas?
Thanks
Chris

···

--
Posted via http://www.ruby-forum.com/.

Whats the best way of running a JRuby script from Ruby?

I know you can do this : `jruby script.rb`, but that won't allow passing
of parameters from ruby to jruby.

You could pass parameters by passing the Object.inspect string and then
doing an eval:

`jruby script/rb #{object.inspect}`
.

I suppose you could serialize your objects/parameters and pass it though
that way.

Any decent ideas?

Hmm are Ruby and JRuby drb compatible? Maybe that would do the trick for you?
Would be great BTW.

Thanks
Chris
--
Posted via http://www.ruby-forum.com/\.

Cheers
Robert

···

On 8/16/07, Chris Richards <evilgeenius@gmail.com> wrote:

--
[...] as simple as possible, but no simpler.
-- Attributed to Albert Einstein

I just downloaded JRuby 1.0, JRuby as Server or client, Ruby as client
or server, does not matter works out of the box, like charm.
Chris this really should do the trick for you, no?
Something like :
Ruby:

···

On 8/16/07, Robert Dober <robert.dober@gmail.com> wrote:

Hmm are Ruby and JRuby drb compatible? Maybe that would do the trick for you?
Would be great BTW.

-------
require 'drb'
class MyParams
    attr_reader :value
    def initialize value
      @val = value
   end
end

DRb.start_service("druby://localhost:4646", MyParams.new(
theObjectYouWant2Pass ));

system "jruby... " ### this might be tricky, use either fork or Threading
sleep 42
DRb.stop_service

And in JRuby

require 'drb'
DRb.start_service
incoming = DRbObject.new(nil, "druby://localhost:4646")
object = incoming.value
DRb.stop_service

do whatever you want with value...

HTH
Robert

--
I'm an atheist and that's it. I believe there's nothing we can know
except that we should be kind to each other and do what we can for
other people.
-- Katharine Hepburn

DRb is the answer and it does work like a charm!!

···

--
Posted via http://www.ruby-forum.com/.

DRb is the answer and it does work like a charm!!

So now i can have a jruby drb server purely dedicated to just creating
nice JFreeChart charts for me!

···

--
Posted via http://www.ruby-forum.com/\.