title: dynamically loading classes from a ImageJ plugin
body: <p>I am having problems dynamically loading a java class from a dynamically loaded class.</p>
  
  <p>My class is an <code>ImageJ</code> plugin and it loads other modules dynamically through <code>classloader</code>. I have <code>NoClassDefFoundError</code> when loading the module that references to something that is in the same package as the <code>ImageJ</code> plugin. </p>
  
  <p>What I exactly do is:</p>
  
  <ol>
  <li>ImageJ loads plugin (A)</li>
  <li>(A) gets system class loader</li>
  <li>(A) add jar url to class loader </li>
  <li>(A) try to load the desired class (B) in the jar using <code>Class.forName</code></li>
  </ol>
  
  <p>I am unable to load class B because I get a <code>NoClassDefFoundError</code> caused by B pointing to a class in A that was not found in the current classloader.</p>
  
  <p>I think I need to use the same classloader <code>ImageJ</code> used for loading plugins on the first place to be able to load my modules and still find references to jars previously loaded by <code>ImageJ</code>. I would like to do this without having to recompile <code>ImageJ</code>.</p>
  
  <p>Is there any way to fix this problem without having to indagate <code>ImageJ</code> code or having to modify it?</p>
  
  <p>pseudo classes example</p>
  
  <pre><code>package a;
  class A extends PlugInFrame {}
  
  
  package a;
  class C extends MyOwnPlugIn {}
  </code></pre>
  
  <hr>
  
  <pre><code>package b;
  import a;
  class B extends C {}
  </code></pre>