7

Please tell me if it is possible to do the following:

  • create an instance of a specific class in Java
  • pass it to JRuby to do something with it
  • continue using the "modified" version in Java

May you provide a small working example?

EDIT: It turns out that embedding was the simplest way to achieve this. More information is available on Embedding JRuby.

Roy Tinker
  • 10,044
  • 4
  • 41
  • 58
Geo
  • 93,257
  • 117
  • 344
  • 520

3 Answers3

4

Yes it's possible. This page on the JRuby wiki should get you started.

jshen
  • 11,507
  • 7
  • 37
  • 59
digitalsanctum
  • 3,261
  • 4
  • 29
  • 43
1

This was the solution I used : Direct JRuby embedding

James Moore
  • 8,636
  • 5
  • 71
  • 90
Geo
  • 93,257
  • 117
  • 344
  • 520
  • Looks like you have some link rot here, is there another link that could be used here (and hopefully summarized in the answer to avoid this problem in the future?) – Tim Post Sep 18 '11 at 20:02
0

It depends on what you mean by "do something". If you mean "redefine a method", then the answer is no, not really. The new method will be used by jruby, but any calls to the method in java will continue to invoke the old method.

James Moore
  • 8,636
  • 5
  • 71
  • 90