你如何使用JRuby创建一个Java小程序? [英] How do you create a Java applet using JRuby?
问题描述
我要创建使用JRuby的Java小程序。也就是说,我想创建一个Java小程序用Ruby code内通过JRuby的运行做的所有东西的GUI。
我在寻找如何做到这一点上手一个简单的例子。
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.
推荐答案
检查这些链接...
JRubyApplet从我们codeBase的:<一href=\"https://github.com/jruby/jruby/blob/master/src/org/jruby/JRubyApplet.java\">https://github.com/jruby/jruby/blob/master/src/org/jruby/JRubyApplet.java
JRubyApplet from our codebase: https://github.com/jruby/jruby/blob/master/src/org/jruby/JRubyApplet.java
建立签名Applet Rake任务:<一href=\"https://github.com/jruby/jruby/blob/master/rakelib/applet.rake\">https://github.com/jruby/jruby/blob/master/rakelib/applet.rake
Rake tasks for building a signed applet: https://github.com/jruby/jruby/blob/master/rakelib/applet.rake
有关jruby.org/tryjruby页来源:<一个href=\"https://github.com/jruby/jruby.github.com/blob/master/www/tryjruby.html\">https://github.com/jruby/jruby.github.com/blob/master/www/tryjruby.html
Source for jruby.org/tryjruby page: https://github.com/jruby/jruby.github.com/blob/master/www/tryjruby.html
有关你的情况,你可能已经用Java小程序,自举一个org.jruby.embed.ScriptingContainer实例,然后给它的小程序实例,以便它可以在一个Ruby脚本添加您的UI元素。任何在applet的jar可以直接加载,例如需要'my_applet.rb'将查找在罐子/my_applet.rb。
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.
享受!
这篇关于你如何使用JRuby创建一个Java小程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!