title: java Nashorn ReferenceError
body: <p>I'm making some experiences with nashorn.</p>
  
  <p>For that I made this simple code in java, where I want to use a custom Object that I defined.</p>
  
  <pre><code>       ScriptEngine engine = new 
         ScriptEngineManager().getEngineByName("javascript");
         System.out.println("engine = " + engine.getClass().getName().toString());
  
         engine.put("id", "2");
         System.out.println("id = " + engine.eval("id"));
  
         Object person = engine.eval("importClass(Data.com.personal.Person)");
  </code></pre>
  
  <p>I returns the following error:</p>
  
  <pre><code>        Exception in thread "main" javax.script.ScriptException: ReferenceError: "importClass" is not defined in &lt;eval&gt; at line number 1
  </code></pre>
  
  <p>Now I google it and they say to use:</p>
  
  <pre><code>     load("nashorn:mozilla_compat.js");
  </code></pre>
  
  <p>but I'm a little confuse to where i put (or how to use) this load function?</p>
  
  <hr>
  
  <p>UPDATE</p>
  
  <p>to import class work with nashorn it's necessary make the call like this:</p>
  
  <pre><code>    engine.eval("importClass(com.personal.Person)");
  </code></pre>
  
  <p>for some reason it wasn't obvious to me :P</p>