Java code executing a Ruby script:
ruby = new ScriptingContainer(LocalVariableBehavior.PERSISTENT);
ruby.put("MyJavaClass", MyJavaClass.class);
ruby.runScriptlet(readFile("Test.rb"));
MyJavaClass code:
public class MyJavaClass {
public MyJavaClass(String name) {
System.out.println("I got a name: " + name);
}
}
Ruby code within Test.rb:
someInstance = MyJavaClass.new("Joe")
This is what I tried to initialize a Java object within a Ruby script using JRuby. It did not work.