Skip to content
Ben Langfeld edited this page Apr 11, 2012 · 10 revisions

JRuby is an entire Ruby interpreter written in Java. An Adhearsion application running with JRuby has all of the following benefits:

  • Full integration with the Java standard library and all third-party libraries. Examples:
    • Using ActiveRecord or Hibernate with JDBC to connect to an obscure legacy database
    • Using Smack for solid XMPP support
    • Potentially write dialplans in Java or even other Java languages such as JavaScript, Python, etc.
  • Use Java with much cleaner syntax than normal
  • Robust, native threading, including the ability to run across multiple CPUs
  • Foreign Function Interface (FFI) support using Java Native Interface (JNI)
  • Access to many Java-only technologies such as JMX

Installing JRuby

Installing JRuby is quite easy and involves the following:

  • Ensure you have a recent JDK, version 1.4 or greater
  • Install RVM
  • Install jruby (rvm install jruby)
  • Have fun!

A nice Getting Started tutorial with more information can be found on the JRuby project website. You may also find additional installation details on the JRuby Wiki here.

Using Java within Adhearsion

When Adhearsion is running with JRuby, you can simply require a .jar file. If you created a plugin, the code below would go in it somewhere:

require 'smack.jar'
import org.jivesoftware.smack.XMPPConnection

connection = XMPPConnection.new "jabber.org"
connection.login "user", "password"