且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用 JRuby 创建 Java 小程序?

更新时间:2023-11-19 21:11:46

查看这些链接...

来自我们代码库的 JRubyApplet: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

用于构建签名小程序的 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 页面的来源: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 实例,然后将 Applet 实例提供给它,以便它可以在 Ruby 脚本中添加您的 UI 元素.小程序 jar 中的任何内容都可以直接加载,例如require 'my_applet.rb' 将在 jar 中查找/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.

享受吧!