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
Register / Login
JavaRanch » Java Forums » Other Languages » Ruby
Reply 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: 144
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: 11945
Where did you hear that Ruby can load Java libraries?


Author of Test Driven (Manning Publications, 2007) [Blog] [HowToAskQuestionsOnJavaRanch]
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18652
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: 144
Thanks, you guys--I think I had it wrong. It makes pretty clear sense to use JRuby if you want to call java libraries.
 
IntelliJ Java IDE
 
subject: If Ruby can load java libraries, why use JRuby?
 
Threads others viewed
Ruby in Java *--------* Java in Ruby
Beginning Ruby Question
Groovy vs Ruby vs Java
Writing JUnit 4 tests in JRuby
How in depth does the new Ruby In Practice book cover JRuby?
developer file tools