Connecting Ruby and Java is possible these days. Like integrating C++ in Java using Java Native Interface (JNI) you can integrate ruby’s code to java using Ruby to Java Bridges. Over the last six years, Intergrating ruby’s code on Java solutions have emerged. Although how they solve the problem are similiar. The real implementation are very different.
List of bridge software to Connecting Ruby to Java Programming
Here are the list of bridge software that you can use to integrate ruby on java enviroment
- Ruby/Java Bridge (RJB), This is a bridge that implement the Java Native Interface (JNI). Java’s JNI is used primarily for C to Java integration and it’s a high-performance API. The performance is good as well as the package is under active development. Although this bridge is more difficult to set up than some of the others, especially on alternate platforms such as Microsoft Windows Operating System. But once it’s set up, it’s easy to use.
- Yet Another Java Bridge (YAJB), YAJB provides a communication facility between Ruby and Java. The current implementation is written in Java and ruby on rails so as to run on many platforms. This bridge uses a common communication strategy called XML remote procedure calls. YAJB is very easy to install and configure. You don’t need a C compiler to deploy it; you just drop the libraries into the right directory. This bridge is reasonably up-to-date, and seems to be actively maintained. There’s an active mailing list. YAJB is a coarse, tactical tool.
- Ruby to Java Native Interface (RJNI), RJNI uses the Java Native Interface (JNI) to provide a Ruby to Java bridge with high performance potential. It’s not under active development, and goes only one way (for example, you can’t do callbacks from Java, so rich user interface development is all but impossible). It was last updated more than a year ago, and it works only on Unix platforms, not Windows.
- RJava, RJava is a simple Ruby-to-Java interface. Rjava uses TCP/IP to communicate between Java and Ruby. Because it is not under active development, you should not be used it on production systems.
The most known Bridge software of Ruby to Java Programming is Ruby/Java Bridge (RJB).
Pros and Cons using Ruby to Java Bridge Software
The most prominent of these bridge software are YAJB and RJB. The others (Rjava and RJNI) are no longers actively maintained. These bridge software have some definite advantanges :
- They require only small libraries, and you can get them running relatively quickly (though the JNI versions have to be compiled).
- The API for both of the major implementations is focused and easy to understand.
- You can easily cross boundaries with a simple method call.
Although they have many advantages, they have limitations too. such as
- They don’t seek to make transparent, bidirectional access between languages. You won’t be able to build frameworks that have much bidirectional communication, such as plugging a Ruby business rule into a Java rules engine, for example.
- They don’t seek broader integration to programming languages beyond Java or Ruby. Your interfaces will be usable only between Ruby and Java.