How to create a Java applet using JRuby?

I want to create a Java applet using JRuby. That is, I want to create a Java applet with Ruby code inside, run by JRuby, to make all the GUI stuff. I am looking for a simple example of how to do this to get started.

+6
java ruby jruby applet
source share
2 answers

Check out these links ...

JRubyApplet from our code base: https://github.com/jruby/jruby/blob/master/src/org/jruby/JRubyApplet.java

Rake the task of creating a signed applet: https://github.com/jruby/jruby/blob/master/rakelib/applet.rake

Source for jruby.org/tryjruby: https://github.com/jruby/jruby.github.com/blob/master/www/tryjruby.html

In your case, you will likely have an applet in Java, a bootstrap instance of org.jruby.embed.ScriptingContainer, and then feed it an instance of Applet so that it can add your user interface elements to the Ruby script. Any applet content can be loaded directly, for example. require 'my_applet.rb' will look for / my _applet.rb in the bank.

Enjoy it!

+7
source share

In addition to the links published earlier, an example of JRuby is provided in an applet working live: http://www.jruby.org/tryjruby

0
source share

All Articles