On 8/15/06, Greg W. [email protected] wrote:
See, now for whatever reason, this is one of those things that my
brain is refusing to grab a hold of and just “get.”
I can understand running Ruby inside Java. Easy concept. However, I
don’t want to run Ruby inside Java, I just want to pass some data
from Ruby to Java. Have Java do some things, and then pass some data
back to Ruby. Without using web services. Once inside Java, the code
will be Java.
I’ll try to make it a bit more clear; I know that for a non-Java
it’s a little weird.
JRuby is an implementation of Ruby, plain and simple. The difference is
instead of being written in C and running as a C program, it’s written
Java and runs as a Java program. That does necessitate that it’s running
inside a JVM, like any Java program, but otherwise it works like Ruby.
can run “jruby script.rb” and it will run, like it would with normal
However you can call Java code from inside that script, and it’s pretty
to do. It’s somewhat akin to Kernel#syscall for normal Ruby…you’re not
launching another process or making a remote call to call Java…JRuby
does some magic to make the call happen and appear to be normal Ruby
Other than calls to Java, a Ruby script in JRuby looks like like a Ruby
script in normal Ruby. JRuby isn’t perfect yet, but it can run most Ruby
core libraries and simple Rails apps. It’s under heavy development, and
we’re making great progress on performance and compatibility.
That said, JRuby may or may not be the option you want. If you prefer to
stock Ruby, or if you’re not really into or experienced with Java in
general, JRuby may be overkill for your needs. The Ruby/Java bridges
allow you, theoretically, to call your Java library of choice as in
with only a little more overhead. You’ll need to choose what works for
JRuby is usually the best option if you have Java libraries you want to
able to use from your Ruby code, but it’s not always the best option and
certainly not the only option. If you do choose to go down the JRuby
the other devs and I will certainly try to help you make your app work
Incidentally, there’s now an additional option for remoting with JRuby:
Apparently some users now have DRb working well enough under JRuby that
could put your Java code behind a DRb service rather than behind a SOAP
service. That’s pretty compelling considering the complexity and
SOAP. We also have plans in the future to implement “smart” proxies to
DRb automatically to the various types of Java EE services.