File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Ruby and the fly likes If Ruby can load java libraries, why use JRuby? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Languages » Ruby
Bookmark "If Ruby can load java libraries, why use JRuby?" Watch "If Ruby can load java libraries, why use JRuby?" New topic
Author

If Ruby can load java libraries, why use JRuby?

Benjamin Weaver
Ranch Hand

Joined: Apr 08, 2003
Posts: 161
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

Joined: Jan 23, 2002
Posts: 11962
    
    5
Where did you hear that Ruby can load Java libraries?


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
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.


"I'm not back." - Bill Harding, Twister
Benjamin Weaver
Ranch Hand

Joined: Apr 08, 2003
Posts: 161
Thanks, you guys--I think I had it wrong. It makes pretty clear sense to use JRuby if you want to call java libraries.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: If Ruby can load java libraries, why use JRuby?
 
Similar Threads
How in depth does the new Ruby In Practice book cover JRuby?
Beginning Ruby Question
Groovy vs Ruby vs Java
Writing JUnit 4 tests in JRuby
Ruby in Java *--------* Java in Ruby