title: Run java compiled class in JRE and ERROR: Could not find or load main class
body: <p>I have a linux system where I have JRE installed in my /usr/lib/jvm/java1.7/jre/bin</p>
  
  <p>I am trying to find the heap size of the java process running on this system using this JRE.
   I have written the following complied and trying to run it. 
   My Java class:</p>
  
  <pre><code>public class GetHeapSize {
       public static void main(String[] args) {
  
          //Get the jvm heap size.
          long heapSize = Runtime.getRuntime().totalMemory();
  
          //Print the jvm heap size.
          System.out.println("Heap Size = " + heapSize);
      }
  }
  </code></pre>
  
  <p>I have both my .java and .class in the same directory. I have compiled the code on other machine [ which should not matter ]</p>
  
  <p>When I run at command prompt </p>
  
  <pre><code>/home/codesrc&gt;java GetHeapSize.class
  Error: Could not find or load main class GetHeapSize.class
  </code></pre>
  
  <p>Can some one please suggest what am I doing wrong.
  For just in case needed:</p>
  
  <pre><code>/home/codesrc&gt;java -version
                java version "1.7.0_09"
                Java(TM) SE Runtime Environment (build 1.7.0_09-b05)
                Java HotSpot(TM) 64-Bit Server VM (build 23.5-b02, mixed mode)
  </code></pre>