# Can RoR call java or C code

**URL:** <https://www.ruby-forum.com/t/can-ror-call-java-or-c-code/83559>\
**Category:** Rails\
**Created:** [January 27, 2007, 2:35am UTC](https://www.ruby-forum.com/t/can-ror-call-java-or-c-code/83559 "2007-01-27T02:35:38Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [January 27, 2007, 2:35am UTC](https://www.ruby-forum.com/t/can-ror-call-java-or-c-code/83559/1 "2007-01-27T02:35:38Z")

</div>

Hi  
I posted this a while back but it has not yet showed up. I dont know  
what happened last time… so posting again

1. Can RoR call C or java third party code?
2. Does it support File I/O ?

thanks  
Rupak

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [January 27, 2007, 2:22pm UTC](https://www.ruby-forum.com/t/can-ror-call-java-or-c-code/83559/2 "2007-01-27T14:22:04Z")

</div>

You can write extensions to the Ruby language in C to call third-party  
code. RoR itself does not provide any such facilities.

You could take a look at the JRuby project. This allows Ruby to run on  
top of the JVM and provides full access to the Java platform. It is not  
currently mature enough to support RoR unfortunately. ☹

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [January 27, 2007, 2:23pm UTC](https://www.ruby-forum.com/t/can-ror-call-java-or-c-code/83559/3 "2007-01-27T14:23:23Z")

</div>

P.S. RoR does support file I/O - but only on the server of course.

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [January 27, 2007, 6:04pm UTC](https://www.ruby-forum.com/t/can-ror-call-java-or-c-code/83559/4 "2007-01-27T18:04:13Z")

</div>

removed\_email\_address@domain.invalid wrote:

> >

This might help:  
[http://www.rubyinside.com/writing-your-own-ruby-extension-with-c-366.html](http://www.rubyinside.com/writing-your-own-ruby-extension-with-c-366.html)

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [January 27, 2007, 6:59pm UTC](https://www.ruby-forum.com/t/can-ror-call-java-or-c-code/83559/5 "2007-01-27T18:59:02Z")

</div>

> 1. Can RoR call C or java third party code?

Yes. Both. Those aren’t really features of RoR but of Ruby. There  
is a whole chapter in the Pickaxe book about extending Ruby with C.  
As for Java, try RJB the Ruby Java Bridge. In fact I just wrote a RoR  
project that uses itext, a java library, via RJB. It worked very  
well.

> 1. Does it support File I/O ?

Of course.

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [January 27, 2007, 7:13pm UTC](https://www.ruby-forum.com/t/can-ror-call-java-or-c-code/83559/6 "2007-01-27T19:13:05Z")

</div>

On Jan 27, 7:22 am, Mick S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> You can write extensions to the Ruby language in C to call third-party  
> code. RoR itself does not provide any such facilities.
> 
> You could take a look at theJRubyproject. This allows Ruby to run on  
> top of the JVM and provides full access to the Java platform. It is not  
> currently mature enough to support RoR unfortunately. ☹

Actually JRuby does run RoR right now, but with caveats (known issues)  
and it’s better at 1.1.6. However we’ve been demoing basic Rails 1.2.1  
apps running under JRuby almost weekly, and we’re making a major push  
over the next month to cleanup all the remaining failures.

- Charlie
