title: Problems dynamically loading a Java class with Groovy
body: <p>I am porting a Jelly script to Groovy and I am stuck on one line of code from the Jelly script which implements the <a href="http://commons.apache.org/jelly/tags.html#core%3anew" rel="nofollow">new</a> tag:</p>
  
  <pre><code>&lt;j:new var="builder" classLoader="${it.class.classLoader}" className="hudson.plugins.emailext.plugins.ContentBuilder"/&gt;
  </code></pre>
  
  <p>I know this is loading a class, but I cannot get Groovy to do the same thing.  I have tried several different ways using various class loader examples I have found, but I always get error(s), typically something like "unable to resolve class".  One problem is that I don't know if I need to use a file system path:</p>
  
  <pre><code>C:\Jenkins\plugins\email-ext\WEB-INF\classes\hudson\plugins\emailext\ContentBuilder.class
  </code></pre>
  
  <p>Or if I need to use a URL (and I don't know the URL to the file nor do I know if Jenkins will let me access the file if I did know the URL).</p>
  
  <p><strong>So the question is how do I instantiate</strong> <a href="http://www.jarvana.com/jarvana/view/org/jvnet/hudson/plugins/email-ext/2.7/email-ext-2.7-javadoc.jar!/hudson/plugins/emailext/plugins/ContentBuilder.html" rel="nofollow">hudson.plugins.emailext.plugins</a></p>
  
  <p>P.S. The old Jelly script and the new Groovy script are both being used as email templates with <a href="https://wiki.jenkins-ci.org/display/JENKINS/Email-ext+plugin" rel="nofollow">Jenkins Email-Ext plugin</a>.  The Jelly script works, but I want it in Groovy.</p>