title: trying to run javascript program inside java generates EvaluatorException: Constructor for "ReferenceError" not found
body: <p>I am trying to import <code>env.js</code> inside a java program</p>
  
  <pre><code>import org.mozilla.javascript.Context;
  import org.mozilla.javascript.ContextFactory;
  import org.mozilla.javascript.Scriptable;
  import org.mozilla.javascript.tools.shell.Main;
  
  public class ScriptRun {
  
      public static void main(String[] args) throws Exception {
          System.out.println(System.getProperty("java.version"));
          Context cx = ContextFactory.getGlobal().enterContext();
          Scriptable scope = cx.initStandardObjects();
          cx.setOptimizationLevel(-1);
          cx.setLanguageVersion(Context.VERSION_1_7);
          Main.processSource(cx, "C:\\Java\\rhino1_7R4\\rhino1_7R4\\env.rhino.1.0.js");\\ &lt;== this generates exception
          Context.exit();
      }
  }
  </code></pre>
  
  <p>this is generating </p>
  
  <pre><code>Exception in thread "main" org.mozilla.javascript.EvaluatorException: Constructor for "ReferenceError" not found. (C:\Java\rhino1_7R4\rhino1_7R4\env.rhino.1.0.js#75)
  at org.mozilla.javascript.DefaultErrorReporter.runtimeError(DefaultErrorReporter.java:77)
  at org.mozilla.javascript.Context.reportRuntimeError(Context.java:913)
  at org.mozilla.javascript.Context.reportRuntimeError(Context.java:969)
  </code></pre>
  
  <p>line 75 in env.rhino.1.0.js is</p>
  
  <pre><code>try { dontCare = globalize; }
  </code></pre>
  
  <p>the code block it is in is</p>
  
  <pre><code>var countOfMissing = 0, dontCare;
  try { dontCare = globalize; }
  catch (ex){ globalize = function(){ return {}; };
              countOfMissing++; }
  </code></pre>
  
  <p>I think this piece of javascript is fine. What it is failing on is trying to create the <code>ReferenceError</code> and failing there. My assumption was this is supposed to be part of the javascript engine.</p>
  
  <p>has anyone come across this?</p>
  
  <p>jdk is 1.7.0_45</p>