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

On 8/16/07, Chris R. [email protected] wrote:

.

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, Robert D. [email protected] wrote:

Hmm are Ruby and JRuby drb compatible? Maybe that would do the trick for you?
Would be great BTW.
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:


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

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

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!

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs