RJava enables Ruby to use Java classes in ruby programs using ruby-like syntax.
Probably LGPL or GPL.
This simple program lets the JVM print "Hello World!" on its console window.
require "java"
include JAVA
JVM.start_tcp().import("java.lang.System").out.println("Hello World!")
require "java"
include JAVA
def create_pane
pane = @jvm.new("javax.swing.JPanel", @jvm.new("java.awt.GridBagLayout"))
gbc = @jvm.new("java.awt.GridBagConstraints")
label = @jvm.new("javax.swing.JLabel", "Some Text")
gbc.fill = gbc.jclass.BOTH
pane.add(label, gbc)
pane
end
@jvm = JVM.start_tcp
jframe_class = @jvm.import("javax.swing.JFrame")
jframe = jframe_class.new("Ruby-Swing-Sample")
jframe.setSize(300, 200)
jframe.setDefaultCloseOperation(jframe_class.DISPOSE_ON_CLOSE)
jframe.setContentPane(create_pane)
jframe.setVisible(true)
The current implementation is an early preview with several limitations:
The idea for this project was born during the First European Ruby Conference in Karlsruhe (Germany) on June 21th - 22th. I do the development in my spare time when my wife and my new born son let me do. Therefore my progress is very slow.
For installation problems, critique and suggestions please feel free to send me an email at rjava@spricom.com. Due to lack of time, I might not be able to answer each mail individually.