示例#1
0
  /**
   * Create a new com.netscape.javascript.Context.
   *
   * @return the newly instantiated Context
   */
  public Object createContext() {
    // this is stolen from Main.java
    cx = new Context();
    ((Context) cx).enter();

    global = new Global();
    ((Context) cx).initStandardObjects(global);

    String[] names = {"print", "quit", "version", "load", "help", "loadClass"};
    try {
      global.defineFunctionProperties(names, Main.class, ScriptableObject.DONTENUM);
    } catch (PropertyException e) {

      throw new Error(e.getMessage());
    }

    return cx;
  }