JRuby simple example

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!'))

$ 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.

One thought on “JRuby simple example”

  1. Pingback: Travel Montserrat

Leave a Reply

Your email address will not be published. Required fields are marked *