JRuby is a Java implementation of the Ruby interpreter, with an tightly integrated with Java. In this examples you will call swing components.

On Ubuntu you can get it installing the package jruby (a meta package for jruby1.0 or jruby0.9 packages).

To test it save this code as test.rb and invocate it with the jruby interpreter:

require 'java'

frame = javax.swing.JFrame.new()
frame.getContentPane().add(javax.swing.JLabel.new('Hello, JRuby World!'))
frame.setDefaultCloseOperation(javax.swing.JFrame::EXIT_ON_CLOSE)
frame.pack()
frame.set_visible(true)

$ jruby1.0 test.rb

Hello JRuby World

ps: We did not define a close method, so to close this windows you’ll need to kill its process or press Ctrl+C in your terminal.