Desktop Application Development in JRuby

Is JRuby a realistic candidate for authoring complex desktop applications?


UPDATE (Jan. 30, 2009): Our client has cleared us to spill our guts on the details of the project discussed here now that it’s complete… Ruby for Desktop Applications? Yes we can.

Last spring Karlin Fox and I became involved with a project that aimed to rewrite an old DOS app as a modern desktop app. Once Java was selected as our platform we immediately began to consider if JRuby could play a role in the project. We discussed several levels of JRuby usage. We had applied JRuby in the past for testing and various tool-smithing tasks, but we wanted to see JRuby play a larger role. The decision was made to write as much of the application as possible in Ruby.

We are now in the 22nd week of the project and there have been no regrets with our decision to use JRuby. It continues to excite me that I get to use my favorite programming language to test and create an attractive desktop application. Micah Alles joined the project in the 10th week increasing the team to three members. The code is now being exercised by 793 RSpec examples at the unit level and 73 integration examples that exercise the app just below the GUI. The application has reached a size of 187 classes which contribute to 7,890 lines of code.

The application is a simulation that shows a two dimensional topological view of connected nodes that the user gets to interact with. Users can load different topologies into the application. Data is gathered while the simulation runs and the user has the ability to view various reports about their performance.

We are using the Batik SVG Toolkit to render the topology. The rendered SVG is interactive. Clicking on components brings up swing dialogs. Using SVG gave us the ability to easily integrate artwork created by the design team.

Using Swing components through JRuby has been much easier than with straight Java. We have built several complicated widgets using complex components like JTable. For layout purposes we have used Cheri::Swing, Profligacy, translated output from the Netbeans GUI designer, and rolled some views by hand. Our only setbacks have been the slow progress of Java integration features in JRuby and the lack of a comprehensive Swing layout manager.

We are bundling all of the application’s Ruby code, Ruby and Java dependencies, and JRuby itself into a single executable jar which we deliver weekly at the end of each iteration. Our target OS is Windows, but we all develop on OS X and Linux as well.

We should be able to provide some screen shots by springtime when the application is officially released, and will post anything noteworthy during the rest of our development effort. Please share any JRuby success stories you have with us and be sure to post them on the JRuby wiki.
Thank you JRuby team!

  • Yesh says:

    In case someone wants to make this work with java LAF here is what I did to (apologize if formating is not right) I got this solution from I also added substance.jar to vendor dir and modified the build.xml to include the jar. Thanks for the article.

    public class Main {
    public static void main(String[] args) {
    java.awt.EventQueue.invokeLater(new Runnable() {
    public void run() {
    try {
    }catch (Exception e) {
    Ruby runtime = JavaEmbedUtils.initialize(new ArrayList());
    RubyRuntimeAdapter evaler = JavaEmbedUtils.newRuntimeAdapter();
    evaler.eval(runtime, “require ‘com/atomicobject/hello_world/lib/application_bootstrap'”);



  • Interesting post.

    I have high hopes that IronRuby will be a viable candidate for real world development as well.

  • Shawn Crowley Shawn Crowley says:


    We have used Matisse’s GroupLayout manager using NetBeans and Profilgacy.

    What we mean by a “comprehensive Swing layout manager,” is a layout manager that is syntactically light when dealing with deep GUI hierarchies.

    The Matisse GUI Builder is really nice, but it generates Java code and XML instead of Ruby and our views are all written in Ruby. We have discussed writing some scripts to convert the generated NetBeans code and XML into Ruby code, but have not done so yet.

  • Navjeet says:

    Thank you for sharing your experiences with JRuby. Looks like the combination of JRuby and Cherry Swing can take out a lot of pain from Java Swing UI development.

  • Shawn Anderson says:

    Karlin & Crowley
    Thanks for the info. I have used a similar setup for a small desktop app, utilizing ruby and swing. I’ve found that distributing a jar or an OS X app is much easier than distributing raw ruby apps or rubyscript2exe’d apps.

  • Rod Hilton says:


    I’m very interested in some of the techniques you used to package up and deploy jruby desktop applications.

    If you get a chance, could you please e-mail me at the address provided so we can chat?

    I’d greatly appreciate it.


  • james britt says:

    A lot has happened since 2007, and hands down Monkeybars ( is now the best choice for desktop apps in JRuby. Cheri and Profligacy become painful for anything non-trivial, but Monkeybars was extracted from the development of a complex, real-world application, and it offers just the right layer of abstraction to let you mix Ruby + Swing for desktop sweetness.

  • ij says:

    Have you tried JGoodies FormLayout or MigLayout?

  • Vladimir Sizikov says:

    Great and interesting post.

    Could you please elaborate a bit on two points: 1) “slow progress of Java integration features in JRuby” – what kind of features are you talking about? 2) “lack of a comprehensive Swing layout manager” — is the new layout manager that comes with Matisse is not good enough?


  • Karlin Fox says:

    Hi Vladimir,

    I can answer your first question:

    By “slow progress of Java integration features” we are referring to the lack of some capabilities with Java proxies. For instance, as noted in a post to the JRuby mailing list here, you cannot currently override protected methods correctly. One specific difficulty is that you cannot access protected member variables from within an overridden class in JRuby without using Java reflection.

    This affects anyone trying to make custom JComponent classes in JRuby. In any reasonably complex UI, this usually is required.

    We are pleased to hear that the JRuby team has it in the cards for a later release (see point #3), but until then the workarounds available can hinder straightforward Swing development in JRuby.

  • Vladimir Sizikov says:

    Hi Karlin, thanks for the clarification, now I understand.

  • Comments are closed.