JRuby script causes Java to terminate without throwing exceptions

I am attempting to use a JRuby script from inside a Java program. I can
get the JRuby script engine to run, but after the script finishes, the
program just terminates. Here is some code.

import javax.script.*;

public class ScriptTest1 {
public static void main(String[] args) throws Exception {
ScriptEngineManager factory = new ScriptEngineManager();
ScriptEngine engine = factory.getEngineByName(“jruby”);

  // Evaluate JRuby code from string.
  try {
      engine.eval("puts('Hello!')");              // first
      System.out.println("Never seen");
      engine.eval("t1 = Test.new 'Testy'"); // second
      javax.swing.JOptionPane.showConfirmDialog(
                null, "Sometimes gets here");
  } catch (ScriptException exception) {
      System.out.println("Got error: " + exception);
  }
}

}

The Ruby script prints out the greeting, but the “Never seen” is never
seen, and the confirmation dialog never appears. However, if I comment
out the send engine.eval, then the dialog box DOES appear.

I have no idea what is going on; can anyone shed some light?

JRuby 1.5.2
Java 1.6.0.17
Netbeans 6.9.1
Windows XP SP3

Hi,

On Sat, Nov 13, 2010 at 6:22 PM, Andy J. [email protected] wrote:

}
}

The Ruby script prints out the greeting, but the “Never seen” is never
seen, and the confirmation dialog never appears. However, if I comment
out the send engine.eval, then the dialog box DOES appear.

As far as I tested the above code, I got “Never seen” before the
exception message. Would you try that using simple java command?
It is natural you saw the dialog when the second engine.eval was
commented out. Because you don’t have “Test” class definition, the
second evaluation should fail.

-Yoko