Glad You're Ready. Let's Get Started!

Let us know how we can contact you.

Thank you!

We'll respond shortly.

  • Blog Navigation
Upgrading to JRuby 1.7.0

Why Upgrade?

Two weeks ago, JRuby 1.7.0 was officially released. Here are a few reasons why you might want to upgrade:

  • Bug fixes

    JRuby 1.7.0 fixes many compatibility issues with ruby 1.9. Also, JRuby 1.6.8 is no longer being maintained so fixes from 1.7.0 are not getting backported.

  • Support for invokedynamic

    JRuby 1.7.0 supports the invokedynamic instruction, a new feature in Java 7 which allows the compiler to use duck typing. This means dynamic languages on the JVM will be compiled to faster code.

  • Kernel#exec

    JRuby 1.7.0’s exec function is now a true system exec that replaces the current process, while previously it spawned a new process and waited until the process exited.


I just upgraded my project from 1.6.8 to 1.7.0. It was fairly easy – I took about a day to upgrade our project.

  1. Install JRuby 1.7.0
  2. Bundle
  3. Tweak
  4. Profit!

Detailed How-To

  1. Install jruby-1.7-0.
    It’s as simple as:

    $ rbenv install jruby-1.7.0

    If ruby-build complains that definition not found, you’ll need to upgrade ruby-build.

    Note that if you’re using ruby 1.8.7, you’ll need to install that separately since JRuby 1.7.0 by default uses ruby 1.9.3.

    Drop the new version into your project .rbenv-version file.

  2. Bundle

    $ bundle

    Some gems may fail to install because JRuby 1.7.0 by default doesn’t enable C extensions since they are deprecating this feature. You can turn it back on with the command line option -Xcext.enabled=true – add this to your .rbenv-vars file.

  3. Tweak

    $ rake spec

    If you’re lucky, everything will pass and you can skip straight to step 4.

    Otherwise, here’s a list of the changes I made to port our project over. This is by no means an exhaustive list, so please feel free to comment below.

    • An interesting change in JRuby 1.7.0 is that Java exceptions no longer inherit from ruby Exception. This means that they will not be caught by a standard global rescue. I.e., executing the code below will print ‘Rescued’ under 1.6.8 but will blow up under 1.7.0.

          puts "Rescued"

    If you’re doing a global rescue from Java code, you’ll need to change your code to specifically catch a Java exception class or explicitly rescue Exception (at your own risk).

    • Another change is the behavior of Kernel#exec, which unexpectedly broke one of our dependencies with an unhelpful error message Error: Unable to access jarfile start.jar. In our case, the fix was to change the Kernel#exec call to Kernel#system instead.
  4. Profit!

    Once we finished tweaking it, our application loaded and behaved normally.

Further Notes

You may want to experiment with enabling invokedynamic. It’s turned off by default because some versions of the JDK 7.0 are not fully compatible. To enable it, add -Xcompile.invokedynamic=true into your .rbenv-vars file.

Unfortunately, on my project, we’re sticking with Java 6 due to our dependencies, so no invokedynamic for us – but let me know how that works out if you try it.

  • What is your stack on JRuby? Is it simple JRuby on Rails or maybe something like Torquebox?
    Do you have any issues while upgrading?

  • Fiona Tay

    We are running JRuby on Rails on Jetty using Jetpack (and Mizuno in development). We had a couple minor issues but wasn’t a big deal.

Share This