title: "Error: Could not find or load main class My.class"
body: <p>Im using Java SDK 1.7 on Windows 7 via cmd.exe . Up until a few hours ago everything was working correctly when suddenly I was unable to run my compiled class files, consistently presented with the error in the title.</p>
  
  <p>I seem to be able to compile my My.java file however I am unable to run the resulting class file (My.class). I am constantly given the error "Error: Could not find or load main class My.class". I have tried this with multiple other class files all resulting in the same problem. </p>
  
  <p>My 'Path' environment variable is set to "C:\Program Files (x86)\Java\jdk1.7.0_05\bin" if you were wondering</p>
  
  <p>I have tried reinstalling, creating and setting a classpath variable (no luck), and even directly using the</p>
  
  <p><code>java -cp . My.class</code> </p>
  
  <p>command. </p>
  
  <p>I have tried these posts all to no avail, hence why I'm posting:</p>
  
  <p><a href="https://stackoverflow.com/questions/7485670/error-could-not-find-or-load-main-class">Error: Could not find or load main class</a></p>
  
  <p><a href="https://stackoverflow.com/questions/8966266/error-could-not-find-or-load-main-class-novice">Error: Could not find or load main class- Novice</a></p>
  
  <p><a href="https://stackoverflow.com/questions/7647448/could-not-find-or-load-main-class">Could not find or load main class</a></p>
  
  <p><a href="https://stackoverflow.com/questions/9343977/java-1-7-0-03-error-could-not-find-or-load-main-class">Java 1.7.0_03 Error: Could not find or load main class</a></p>
  
  <p>If it makes any difference my code is :</p>
  
  <pre><code>import javax.swing.JOptionPane;
  
  class My {
      public static void main(String[] args) {
         final double x = 3.2;
         int i = (int)x;
         double m = 0;
         if (x &lt; 4) {
            String saySomething = JOptionPane.showInputDialog(i);
            System.out.println(saySomething);
          }
         else {
            String saySomething = JOptionPane.showInputDialog(i);
            System.out.println("Hello World");
          }
         while (m &lt; 10) {
              System.out.print(" While Loop ");
              m++;
          };
         for (i=1; i &lt; 10; i++) {
             System.out.println("For Loop");
          };
  
      }
  }
  </code></pre>