The following code fails, reporting

org.mozilla.javascript.EcmaError: ReferenceError: "Math" is not
defined. (inline JavaScript#1)

                Scriptable scope = new ImporterTopLevel();
                Context cx = Context.getCurrentContext();
                cx = Context.enter();
                StringBuffer sb = new StringBuffer();
                sb.append("function compute() {\n");
                sb.append("    return Math.sin(42);\n");
                sb.append("}\n");
                cx.evaluateString(scope, sb.toString(), "inline JavaScript", 0,
null);
                Object result = ScriptableObject.callMethod(scope, "compute", 
new
Object[0]);
                System.out.println("Result: " + result);

Can anyone see what I am doing wrong? (This is with Rhino 1.6.7).

Many thanks
Holger
_______________________________________________
dev-tech-js-engine-rhino mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino

Reply via email to