How do you create a Java applet using JRuby?

家住魔仙堡 提交于 2019-12-07 03:21:09

问题


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 do all the GUI stuff. I am looking for a simple example of how to do this to get started.


回答1:


Check out these links...

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

Rake tasks for building a signed applet: https://github.com/jruby/jruby/blob/master/rakelib/applet.rake

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

For your case, you'd probably have the applet in Java, bootstrap an org.jruby.embed.ScriptingContainer instance, and then feed it the Applet instance so it can add your UI elements in a Ruby script. Anything in the applet jar can be loaded directly, e.g. require 'my_applet.rb' will look for /my_applet.rb in the jar.

Enjoy!




回答2:


In addition to the links posted earlier, the following is an example of JRuby in an applet running live: http://www.jruby.org/tryjruby



来源:https://stackoverflow.com/questions/5423888/how-do-you-create-a-java-applet-using-jruby

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!