# Status of Ruby\<-\>Java Interfaces

**URL:** <https://rubytalk.org/t/status-of-ruby-java-interfaces/14041>\
**Category:** ruby-talk\
**Created:** [7 October 2004 20:44 UTC](https://rubytalk.org/t/status-of-ruby-java-interfaces/14041 "2004-10-07T20:44:45Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Cast\_Ent](https://avatars.discourse-cdn.com/v4/letter/c/c67d28/32.png) [@Cast\_Ent](https://rubytalk.org/u/Cast_Ent)\
**Post date:** [7 October 2004 20:44 UTC](https://rubytalk.org/t/status-of-ruby-java-interfaces/14041/1 "2004-10-07T20:44:45Z")

</div>

Hi,

I have a Java program that I'd like to access with Ruby, and I'm  
looking for the 'right tool for the job'. The Java program is an API  
collection of classes that implement a network/socket protocol, and  
I'd like to find a way to have Ruby make the calls, e.g.  
Java:  
public class MySocket {  
&nbsp;&nbsp;&nbsp;&nbsp;private Socket m\_socket; // the socket  
&nbsp;&nbsp;&nbsp;&nbsp;private DataOutputStream m\_dos; // the socket  
output stream  
&nbsp;&nbsp;&nbsp;&nbsp;/////more stuff here....  
&nbsp;&nbsp;&nbsp;&nbsp;private void send( String str) throws IOException {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;m\_dos.write( str.getBytes() );  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;m\_dos.write( EOL);  
&nbsp;&nbsp;&nbsp;&nbsp;}  
}

and I'd like to be able to do something like:  
Ruby:  
mysock=Java.Class.MySockect.new (or something along these lines)  
mysock.send("Hello there")

So what is the state of the world with the various options that exist  
in Ruby for this sort of thing? I've had a brief look at rjni, rjava  
and rjb. Each of which seem to be quite 'alpha'. Any comments,  
suggestions on which is best? Any other options in terms of design?  
Will these work with network/socket classes in Java?

Thanks in advance!  
Jeff

---

<div class="post-metadata">

**Author:** ![James\_Edward\_Gray\_II](https://avatars.discourse-cdn.com/v4/letter/j/ea5d25/32.png) [@James\_Edward\_Gray\_II](https://rubytalk.org/u/James_Edward_Gray_II)\
**Post date:** [7 October 2004 21:24 UTC](https://rubytalk.org/t/status-of-ruby-java-interfaces/14041/2 "2004-10-07T21:24:42Z")

</div>

I have know experience with any Java \<-\> Ruby bridges, but sine I know it exists and I didn't see you mention it, have you checked out JRuby? Just a thought.

James Edward Gray II

> **···**
>
> On Oct 7, 2004, at 3:44 PM, Jeff wrote:
> 
> > So what is the state of the world with the various options that exist  
> > in Ruby for this sort of thing? I've had a brief look at rjni, rjava  
> > and rjb. Each of which seem to be quite 'alpha'. Any comments,  
> > suggestions on which is best? Any other options in terms of design?  
> > Will these work with network/socket classes in Java?

---

<div class="post-metadata">

**Author:** ![Randy\_W\_Sims](https://avatars.discourse-cdn.com/v4/letter/r/b487fb/32.png) [@Randy\_W\_Sims](https://rubytalk.org/u/Randy_W_Sims)\
**Post date:** [8 October 2004 00:25 UTC](https://rubytalk.org/t/status-of-ruby-java-interfaces/14041/3 "2004-10-08T00:25:47Z")

</div>

Is there any particular reason you can't use the ruby sockets interface in this case?

Randy.

> **···**
>
> On 10/7/2004 4:44 PM, Jeff wrote:
> 
> > Hi,
> > 
> > I have a Java program that I'd like to access with Ruby, and I'm  
> > looking for the 'right tool for the job'. The Java program is an API  
> > collection of classes that implement a network/socket protocol, and  
> > I'd like to find a way to have Ruby make the calls, e.g.

---

<div class="post-metadata">

**Author:** ![Mauricio\_Fernndez](https://avatars.discourse-cdn.com/v4/letter/m/e495f1/32.png) [@Mauricio\_Fernndez](https://rubytalk.org/u/Mauricio_Fernndez)\
**Post date:** [7 October 2004 21:56 UTC](https://rubytalk.org/t/status-of-ruby-java-interfaces/14041/4 "2004-10-07T21:56:36Z")

</div>

> \>So what is the state of the world with the various options that exist  
> \>in Ruby for this sort of thing? I've had a brief look at rjni, rjava  
> \>and rjb.

rjb is the only one actively developed atm., so it's probably the best  
option.

I stopped working on rjni when I discovered that the JVM was interacting  
with the signals ruby uses to implement threads (so that Ruby threads  
wouldn't work) and realized that the non-reentrancy of ruby 1.x made  
this all quite hard...

> Each of which seem to be quite 'alpha'. Any comments,  
> \>suggestions on which is best? Any other options in terms of design?  
> \>Will these work with network/socket classes in Java?

The main problem would be when you have multiple Java threads; that's  
hard to handle in 1.x, at least if you're using JNI directly.

> **···**
>
> On Fri, Oct 08, 2004 at 06:24:42AM +0900, James Edward Gray II wrote:
> 
> > On Oct 7, 2004, at 3:44 PM, Jeff wrote:
> 
> --  
> Running Debian GNU/Linux Sid (unstable)  
> batsman dot geo at yahoo dot com
