Class.forName() and ClassNotFoundException
<p>Say I have the following two classes:</p>

<pre><code>public class MyClass {
    public String getDescription() {
        return "MyClass";
    }
}
</code></pre>

<p>and</p>

<pre><code>public class MyClassLoader {
    public static void main (String[] argv) throws ClassNotFoundException {
        Class.forName("MyClass");
        System.out.println("MyClass class was successfully loaded");
    }
}
</code></pre>

<p>If both of these classes are in the default package, it runs fine, the class loads, and the world is beautiful.  (If I were to delete the class <code>MyClass</code>, I would get a <code>ClassNotFoundException</code>, as expected.</p>

<p>However, if they are both in a package (let's say it's a package in Eclipse), and have the </p>

<pre><code>package myClassTestPackage;
</code></pre>

<p>declared in both, I get a <code>ClassNotFoundException</code> when I try to run it.</p>

<p>What causes this issue and how can I fix it?  This is the simplest way I was able to reproduce an error I am experiencing in a much larger program.</p>
