title: GroovyShell: embedded execution
body: <p>I'm trying to embed groovy into a large Java application.</p>
  
  <p>The Java application should load some utility Groovy scripts at startup.</p>
  
  <p>The application should then run other scripts multiple times.  There is also a need to enter some code at a GUI and execute it at user request.</p>
  
  <p>The problem I'm facing is this:</p>
  
  <p>I am loading the startup script like this:</p>
  
  <pre><code>GroovyShell gShell = new GroovyShell();
  gShell.evaluate(new FileReader("scripts/autoload.groovy"));
  </code></pre>
  
  <p>Suppose my autoload.groovy contains:</p>
  
  <pre><code>def prnt(m) {
      println("From Groovy: " + m);
  }
  </code></pre>
  
  <p>This works fine.  But when I want to run a user command using:</p>
  
  <pre><code>gShell.evaluate("prnt 66");
  </code></pre>
  
  <p>I get the error:
  <code>groovy.lang.MissingMethodException: No signature of method: Script2.prnt() is applicable for argument types: (java.lang.Integer) values: [66]</code></p>
  
  <p>How can my user script access the methods already loaded?</p>
  
  <p>Note:  I have also tried "autoload.prnt 88", and still get the error.</p>