JRuby and Java Objects

Please tell me whether the following can be done:

  • instantiate a specific class in java
  • pass it to JRuby to do something with it
  • continue using the "modified" version in Java

Can you provide a small working example?

EDIT: It turns out that nesting was the easiest way to achieve this. Further information is available at Embedding JRuby .

+6
java scripting jruby
source share
3 answers

This was the solution I used: Direct JRuby implementation

+1
source share

Yes it is possible. This page on the JRuby wiki should get started.

+4
source share

It depends on what you mean by "do something." If you mean "override the method", then the answer will be negative, in fact. The new method will be used by jruby, but any method calls in java will continue to reference the old method.

0
source share

All Articles