Pages

Tuesday, March 20, 2012

Exception: sun.org.mozilla.javascript.internal.EcmaError: ReferenceError: "window" is not defined.


// scriptengine testing
        ScriptEngineManager manager = new ScriptEngineManager();
        ScriptEngine engine = manager.getEngineByName("js");       
        try {
            engine.eval(new FileReader("c:\\jquery-1.6.2.min.js"));
            engine.eval(new FileReader("c:\\jquery.validate.js"));
        } catch (FileNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (ScriptException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

Exception:
javax.script.ScriptException: sun.org.mozilla.javascript.internal.EcmaError: ReferenceError: "window" is not defined. (<Unknown source>#16) in <Unknown source> at line number 16
    at com.sun.script.javascript.RhinoScriptEngine.eval(RhinoScriptEngine.java:110)
    at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:232)
    at main.main(main.java:41)


 Similar Issue:

http://stackoverflow.com/questions/6086996/executing-javascript-in-java-opening-a-url-and-getting-links

find more on http://sunfeng.ca/

No comments:

Post a Comment