Can't find Class with Class.forName() but it exists
<p>I have a program in which I am generating classes at runtime (included only variable and associated getters and setters methods). Later I want to fill the classes.</p>

<p>To get the class - I know its Name, but its not in the classpath - I tried .forName() but I always get a ClassNotFoundException.</p>

<p>Here is my example:</p>

<pre><code>Exception in thread "main" java.lang.ClassNotFoundException: com.test.wam.business.wsobjects.Testclass
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at gui.Application.main(Application.java:94)
</code></pre>

<p>And the code: </p>

<pre><code>URLClassLoader urlClassLoader = (URLClassLoader) ClassLoader.getSystemClassLoader();
    DynamicURLClassLoader dynamicURLClassLoader = new DynamicURLClassLoader(urlClassLoader);
    dynamicURLClassLoader.addURL(new URL("file://C:\\dev\\Eclipse_was\\guitest\\generated"));

    Class c = Class.forName("com.test.wam.business.wsobjects.Testclass");

    Object classInstance = c.newInstance();
</code></pre>

<p>The ClassLoader: </p>

<pre><code>public class DynamicURLClassLoader extends URLClassLoader {

public DynamicURLClassLoader(URLClassLoader classLoader) {
    super(classLoader.getURLs());
}

@Override
public void addURL(URL url) {
    super.addURL(url);
}
</code></pre>

<p>}</p>

<p>The full qualified Name to the file (created with eclipse -> copy full qualified Name)  </p>

<blockquote>
  <p>/guitest/generated/com/test/wam/business/wsobjects/Testclass.java</p>
</blockquote>

<p>What is wrong here?</p>