title: Error; Could not find or load main class (Java using Windows CMD)
body: <p>I am trying to compile and run some java files I have made in Eclipse. The full path to the .java file is <code>C:\Users\MYNAME\Documents\Java\Introduction\src\tests\Test.java</code>. <code>tests</code> is the package I created in Eclipse and <code>src</code> is a folder that Eclipse made under <code>Introduction</code> (which is the project name).</p>
  
  <p>In my environment variables, I have the following relevant variable:</p>
  
  <p><code>JAVA_HOME</code> <code>C:\Program Files (x86)\Java\jdk1.7.0_40\bin</code></p>
  
  <p>Under system variables I have the following:</p>
  
  <p><code>CLASSPATH</code> <code>%JAVA_HOME%</code></p>
  
  <p>I go to my cmd and <code>cd</code> into the <code>tests</code> directory (<code>cd C:\Users\MYNAME\Documents\Java\Introduction\src\tests</code>). Then I compile using <code>javac Test.java</code>. This seems to work as I then have a <code>Test.class</code> file under the same directory. Now I want to run the file, I type <code>java Test</code> and I get the error, "could not find or load main class". I've tried a variety of things including appending <code>.class</code> and <code>.java</code> to the end but I keep getting the error. I looked at some answers and docs and I managed to get it to work if I <code>cd</code> into:</p>
  
  <p><code>cd C:\Users\MYNAME\Documents\Java\Introduction\src</code> (i.e, get out of the package)</p>
  
  <p>and then run:</p>
  
  <p><code>java -cp . tests.Test</code></p>
  
  <p>So that seems to temporarily set the class path to the current directory, and run Test from the package <code>tests</code>. However, I want to simply be able to type <code>java Test</code>. I know it's possible as I used to be able to do it, but now for some reason I cannot (I must have changed something along the way...).</p>
  
  <p>Any help is appreciated.</p>