title: "Error: Could not find or load main class" in Windows / DOS Compiler
body: <p>I am new to Java, learning it after programming in C and C++ for a long time.  I am writing on my Windows 7 laptop, using the great guide at docs.oracle.com for my tutorial.  I am working with the Java SE Development Kit 8 (JDK 8) on Windows, and in general, I'm making good progress.</p>
  
  <p>According to this page (<a href="http://docs.oracle.com/javase/tutorial/getStarted/cupojava/win32.html#win32-2c" rel="nofollow">http://docs.oracle.com/javase/tutorial/getStarted/cupojava/win32.html#win32-2c</a>), if I want to compile and run a HelloWorld app in the current directory, I use these commands in a DOS window:</p>
  
  <pre><code>C:\myapplication&gt;javac HelloWorldApp.java      // to compile
  C:\myapplication&gt;java -cp . HelloWorldApp      // to run
  </code></pre>
  
  <p>This worked when I tried it.  But later I expanded HelloWorldApp.java program to include a number of classes.  I decided to create directory called "MyPackage" and move all my code into that directory.  Now I can compile easily enough using this command:</p>
  
  <pre><code>C:\myapplication&gt;javac MyPackage\HelloWorldApp.java      // to compile, this works
  </code></pre>
  
  <p>But how to run this program?  I've tried all of the following:</p>
  
  <pre><code>C:\myapplication&gt;java -cp .\MyPackage HelloWorldApp      // to run, doesn't work
  Error: Could not find or load main class HelloWorldApp
  C:\myapplication&gt;java -cp . MyPackage\HelloWorldApp      // to run, doesn't work
  Error: Could not find or load main class HelloWorldApp
  C:\myapplication&gt;java -cp .\MyPackage MyPackage\HelloWorldApp      // to run, doesn't work
  Error: Could not find or load main class HelloWorldApp
  C:\myapplication&gt;cd MyPackage
  C:\myapplication\MyPackage&gt;java -cp . HelloWorldApp      // to run, doesn't work
  Error: Could not find or load main class HelloWorldApp
  </code></pre>
  
  <p>I've tried additional combos, but can't figure out how to get the program to run.  Any suggestions?</p>
  
  <p>Thanks,
              -Pete</p>