Wiki page: JRuby's Java script (jruby 1.0+) contains great tips and ideas that you can use to get your wrapper
It seems interesting to me to use the module name to access the access area of ββthe imported Java class
Example: create a Ruby Module called JavaLangDemo, which includes classes in the Java package java.lang.
module JavaLangDemo include_package "java.lang"
Now you can prefix the desired Java class name with JavaLangDemo :: to access the included classes:
version = JavaLangDemo::System.getProperties["java.runtime.version"] => "1.5.0_13-b05-237" processors = JavaLangDemo::Runtime.getRuntime.availableProcessors => 2
The article also describes the following topics:
- implementation of the Java interface in Ruby
- Class Name Uncertainty Between Java and Ruby
- "mixing" multiple Java interfaces with Jruby modules in JRuby
- Exception Handling
- Object synchronization for thread safety
and contains a list of useful links to "Related Articles" for more information on the Java Integration Level
Franco rondini
source share