Luckily there is the JSR 223 scripting available in Java6, so the start is relatively easy: get jruby from jruby.org and add it to the java programs classpath, java program code looks like this:
// Define path to jruby libraries
// Get the scripting engine
ScriptEngineManager m = new ScriptEngineManager();
ScriptEngine rubyEngine = m.getEngineByName("jruby");
// Define the puppet script to run as arguments
// read the script
File f = new File("puppet.rb");
BufferedReader br = new BufferedReader(new FileReader(f));
// and execute it
Simple - eh?
Unfortunately is it not that simple (yet).
Passing the argument vector to my script does not yet work in jruby 1.4 cr1 (see JRUBY-4090), so I need to do a work around of defining a script, that sets this and then calls puppet
ARGV << 'example.pp'
Next, puppet is complaining about missing stuff like OpenSSL (which is a difficult beast in jruby, as the standard ruby implementation needs some C code, which can not directly run in jruby).
Also it is somehow complaining about yecht not being found - I still don't really grok setting and properties up things like jruby.lib, jruby.home etc.
If anyone can shed some light on it, I would appreciate it :-)