• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

If Ruby can load java libraries, why use JRuby?

 
Benjamin Weaver
Ranch Hand
Posts: 161
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to try out RoR using Ruby code that draws upon existing Java libraries. Ruby can load Java libraries, no? If this is so, what advantage does JRuby offer over Ruby if Ruby promises to load Java libraries?

I ask because my reflex inclination is to use JRuby or Groovy or something "closer" to Java, just to be safe. But perhaps this is irrational thinking.
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where did you hear that Ruby can load Java libraries?
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It seems to be possible to do this using the Ruby Java Bridge. I haven't used it and can't say much about it. I'm guessing it was more important before JRuby was able to run Rails - if you wanted Java libraries from RoR applications, you needed RJB. Nowadays you can probably use JRuby on Rails instead. I'm guessing that would be better, based only on the limited number of articles I see about RJB - most all of which seem to predate the release of JRuby 1.0. But there may be some cases where JRuby limitations force the user to use C-Ruby, in which case RJB still offers a path to use Java classes.

There's also YAJB (Yet Another Java Bridge), about which I could find even less. Some people apparently had troubles getting this to work, apparently, and it hasn't been updated in a couple years, so I'd be a bit suspicious.

Googling "jruby rjb yajb" (or any two out of those three) yields assorted articles that may be of interest. That's where my limited knowledge comes from; I didn't spend long at it.
 
Benjamin Weaver
Ranch Hand
Posts: 161
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, you guys--I think I had it wrong. It makes pretty clear sense to use JRuby if you want to call java libraries.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic