@Test
public void testJavaClass() throws Exception {

   ScriptEngineManager mgr = new ScriptEngineManager();
   ScriptEngine engine = mgr.getEngineByExtension("java");
   Invocable inv = (Invocable) engine.eval( //
         "public class A {\t\n" + //
               "public String hello(String name) { return \"Hello, \"+name+\"!\"; }\r\n" + //
               "public String help() { return \"hello(...)\"; }\r\n" + //
               "}\r\n");
   Assert.assertEquals("Hello, world!", inv.invokeFunction("hello", "world"));
   Assert.assertEquals("hello(...)", inv.invokeFunction("help"));
   try {
      inv.invokeFunction("unknown");
      Assert.fail("NoSuchMethodException should be thrown.");
   } catch (NoSuchMethodException e) {
      // expected
   }
}