title: Java Scripting With Nashorn (JSR 223) & Pre-compilation
body: <p>I am using Nashorn via JSR 223 to execute small snippets of user entered script:</p>
  
  <pre><code>public Invocable buildInvocable(String script) throws ScriptException {
      ScriptEngine engine = new ScriptEngineManager().getEngineByName(ENGINE);
      engine.eval(functions);
      engine.eval(script);
      return (Invocable) engine;
  }
  </code></pre>
  
  <p>The varying user script calls JavaScript functions that are defined in a static, central library (held in the <code>functions</code> String in the code snippet above).</p>
  
  <p>Every time I want to get hold of an <code>Invocable</code> that I can call from my Java I am constantly having to recompile the large library code.</p>
  
  <p>Is there any way to join a previously compiled piece of code in with new code?</p>