Integrating Ruby-Processing Into An Existing Project
» 24 Jun 2008
"Processing":http://processing.org and "Ruby-Processing":http://github.com/jashkenas/ruby-processing/wikis are really awesome programs for visualizing things and making pretty doodads. Ruby-Processing is great because it uses the JRuby Java bridge to expose all of Processing's immense power to normal Ruby code. Since I use JRuby at work for data processing anyway, Processing seemed like a natural fit for being braindead easy for drawing.
When I went to hack it into my current project I was sorely disappointed to discover that Java was squawking about SecurityExceptions and signer mismatches when run from @jruby@. First, how is code-signing a first-class language function? Second, this appears to be a "known issue":http://jira.codehaus.org/browse/JRUBY-2439. I really hate Java.
Out of frustration, I decided to hack at it and try to recreate the jar so it would be unsigned and happy. Doing this seemed to work as I can now use Processing wherever I want in my application. If you want to use Ruby-Processing in your JRuby app, download "core.jar":http://github.com/schleyfox/ascends_viz/tree/master%2Flib%2Fcore.jar?raw=true and "ruby-processing":http://github.com/schleyfox/ascends_viz/tree/master%2Flib%2Fruby-processing.rb?raw=true and place them wherever your other lib files live.
I created this jar by unzipping the normal ruby-processing core.jar, removing all metadata, and rebuilding it like
jar cf core.jar processing/core/*.class
This seems to work and is generating a "color bar":http://github.com/schleyfox/ascends_viz/tree/master/lib/co2_color_code.rb#L69-94 for me now.