# Re: Non-Java Related jRuby GUI Builder

**URL:** <https://www.ruby-forum.com/t/re-non-java-related-jruby-gui-builder/228964>\
**Category:** JRuby\
**Created:** [May 14, 2013, 12:51pm UTC](https://www.ruby-forum.com/t/re-non-java-related-jruby-gui-builder/228964 "2013-05-14T12:51:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ericw](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/97f17d/32.png) [@ericw](https://www.ruby-forum.com/u/ericw)\
**Post date:** [May 14, 2013, 12:51pm UTC](https://www.ruby-forum.com/t/re-non-java-related-jruby-gui-builder/228964/1 "2013-05-14T12:51:06Z")

</div>

I’ve actually spent a great deal of time researching this question: how  
does one build a GUI app with Ruby? To answer your question here, there  
are  
basically two roads, in MRI (that’s Matz’s Ruby Implementation, the  
non-java ruby) there are a handful of GUI libraries, all of them binding  
to  
one of the C/C++ toolkits: Gnome/GTK, QT, Wx, Gosu(for games) etc. The  
second option is to use JRuby, and either work directly with one of the  
Java toolkits (Swing, SWT, JavaFX) , or use one of the libraries that  
wraps/abstacts/builds on top of those toolkits (Monkeybars, Rubeus,  
Limelight, JRubyFX). Shoes has also been mentioned. It is undergoing a  
rewrite that will use JRuby to provide a wrapper around SWT.

Your suggestion of using one of the MRI GUI libraries, from JRuby, would  
make a lot of sense (portability of code, etc) except that all of those  
libraries bind to various C libraries, and support for that in JRuby is,  
well, currently unsupported. C-Ext support was offered as an experiment,  
in  
a previous version of JRuby (to the best of my understanding) but (again  
to  
the best of my understanding), it was buggy, difficult to maintain, and  
essentially working against the tool. I believe it is still possible to  
invoke JRuby with C-Extension support enabled, but I think for something  
as  
complex as a GUI toolkit, you’d have a hard time getting it working. You  
could possibly bind to one of those libraries via JNI/FFI support, but  
again, at this point you are basically working against the tool,  
creating a  
lot of trouble for yourself, to get something working which would never  
really be a good fit for each other. And quite possibly you would end up  
writing far, far more java code than had you just written your app using  
one of those Java GUI toolkits you seem to want to avoid.

So, after all this research, what have I chosen for my projects going  
forward? JRubyFX, 100%. One, JavaFX is a really nice, modern GUI  
toolkit,  
with a lot of manhours being poured into improving it. It uses CSS for  
styling, has a great GUI builder (SceneBuilder), which produces FXML  
(which  
is quite readable/writable on its own), it performs well, and I could go  
on  
and on. It’s really easy to create your own widgets, components, etc in  
JavaFX (or JRubyFX), and there’s tons of great documentation, blog  
posts,  
and other info easily available for it. Two, JRubyFX provides a very  
ruby-ish wrapper around this, and its getting better all the time as  
byteit101 has been putting a ton of work into making it a top-notch  
framework. Three, efforts are currently underway to get JavaFX running  
on  
iOS and Android (it’s been done in Oracle’s lab, and they’ve opensourced  
their proto-types). This means, it may eventually be possible to write  
JRubyFX apps targeting those devices as well (This one’s a big maybe, of  
course, but Android, at least, should be a very real possibility. This  
stuff about the mobile stuff is just speculation on my part, nobody from  
JRubyFX is doing any work on this stuff at the moment, or looking at it,  
that I know of, but it’s something I am personally very intrigued by).  
Four, javafx provides some really slick packaging tools for easily  
building  
native installers for Windows, Linux and OSX. We’ve already integrated  
that  
support (in basic form, with information on how to customize it  
available)  
into JRubyFX. Finally, Oracle themselves have stated that JavaFX is the  
replacement for Swing, and that they will be phasing Swing out in favor  
of  
FX.

Hope that helped answer your questions, and I hope I’ve convinced you to  
go  
checkout JRubyFX. It’s awesome-sauce.

---

<div class="post-metadata">

**Author:** ![ericw](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/97f17d/32.png) [@ericw](https://www.ruby-forum.com/u/ericw)\
**Post date:** [May 14, 2013, 10:40pm UTC](https://www.ruby-forum.com/t/re-non-java-related-jruby-gui-builder/228964/2 "2013-05-14T22:40:23Z")

</div>

Having tried out a number of GUI toolkits for Ruby, I have been a fan of  
Qt for several years: it is cross-platform, well documented and has  
progressively been developed over a long period.  
Although originally developed for C++ programmers, bindings are  
available for many languages including MRI (qtbindings gem) and Java  
(QtJambi library).  
When I wanted to distribute a closed-source Qt application, I looked  
into JRuby as an alternative to MRI as that would allow me to use  
compiled Ruby code.  
To support this, I developed the qt\_connect gem which interfaces to the  
QtJambi library. It also includes a compatibility layer to even out  
differences between the MRI interface and the JRuby interface.  
The same Ruby Qt application now runs both under MRI and JRuby using the  
qt\_connect gem in combination with the qtbindings gem (MRI) and the  
QtJambi Jars (JRuby)

On the plus: this means I can write a Qt application in Ruby, compile it  
with JRuby and use for instance the Rawr gem to package it all in a  
single jar for distribution.  
It also works well with the Izpack installer if you need a more  
elaborate install process  
On the minus: Qt has a fairly steep learning curve, which pays off well  
in capabilities and performance if you master the use of its many  
(abstract) classes.  
Also the future of the QtJambi is not guaranteed; from a commercial  
product (Trolltech/Nokia) it has now become a community project with an  
unclear licensing situation.

If you are interested to try Qt with Ruby, look at the examples in the  
qt\_connect and qtbindings gems:

[https://rubygems.org/gems/qt\_connect](https://rubygems.org/gems/qt_connect)  
[https://rubygems.org/gems/qtbindings](https://rubygems.org/gems/qtbindings)

Cees Z.
