How do I resolve java.lang.ClassNotFoundException?
<p>I am at a very introductory level of programming with java. I am writing a simple code that involves taking an investment and adding an intrest rate into it. The code is not finished yet but I hav run into the <em>java.lang.ClassNotFoundException</em> error. Since I am so new to java, I have not yet run into this problem before. Where my confusion comes in is the program will compile. I really don't know how to approach this problem. </p>

<p>As I said I dont have a clue about where to start on this, here is the error.</p>

<pre><code>Exception in thread "main" java.lang.NoClassDefFoundError: CDCalc/java
Caused by: java.lang.ClassNotFoundException: CDCalc.java
    at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
</code></pre>

<p>The entire code</p>

<pre><code>    import java.util.Scanner;

public class CDCalc
{
    public static void main(String args[])
        {
            int Count = 0;
            int Investment = 0;
            double Rate = 0;


            Scanner userInput = new Scanner(System.in);

            System.out.println("How much money do you want to invest?");
            int Invest = userInput.nextInt();

            System.out.println("How many years will your term be?");
            double Term = userInput.nextInt();

            System.out.println("Investing: " + Investment);
            System.out.println("     Term: " + Term);

            if (Term &lt;= 1)
            {
            Rate = .3;
            }

            else if (Term &lt;= 2)
            {
            Rate = .45;
            }

            else if (Term &lt;= 3)
            {
            Rate = .95;
            }

            else if (Term &lt;= 4)
            {
            Rate = 1.5;
            }

            else if (Term &lt;= 5)
            {
            Rate = 1.8;
            }

            System.out.println("Total is: " + (Rate * Invest));




        }
}
</code></pre>

<p>I would greatly appreciate any help on this. Thanks</p>

<p><em>edit</em></p>

<p>I apologize, I should have included this. The code did compile just fine, the problem came in when I ran it. I did use javav CDCalc.java and java CDCalc and thats when the error came up. The even stranger thing is I didn't change a thing, closed out terminal and my text editor, deleted the saved files, reopened everything, saved it, compiled it, and it runs fine now. I apologize again for this post but it seems it fixed itself! –</p>
