title: Why am I getting a "java.lang.ClassNotFoundException" error after compiling my program?
body: <p><img src="https://i.stack.imgur.com/ygutF.png" alt="enter image description here">
  <img src="https://i.stack.imgur.com/EWm1Z.png" alt="enter image description here"></p>
  
  <p>I have uploaded two screen shot which are related to my java. When I try to compile a java file, it compiles the java file correctly and creates the .class file successfully, but when I try to run the compiled file it gives an error message. I have attached two screen shots which are related to this problem. Please help me.</p>
  
  <p>Here is the stack trace that I get trying to run with <code>java Test</code> command:</p>
  
  <pre><code>Exception in thread "main" java.lang.UnsupportedClassVersionError: Test : Unsupp
  orted major.minor version 51.0
      at java.lang.ClassLoader.defineClass1(Native Method)
      at java.lang.ClassLoader.defineClass(ClassLoader.java:634)
      at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
      at java.net.URLClassLoader.defineClass(URLClassLoader.java:277)
      at java.net.URLClassLoader.access$000(URLClassLoader.java:73)
      at java.net.URLClassLoader$1.run(URLClassLoader.java:212)
      at java.security.AccessControll.doPrivileged(Native Method)
      at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
      at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
  Could not find the main class: Test. Program will exit.
  </code></pre>
  
  <p>and with <code>java Test.java</code>command:</p>
  
  <pre><code>Exception in thread "main" java.lang.NoClassDefFoundError: Test/java
  Caused by: java.lang.ClassNotFoundException: Test.java
      at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
      at java.security.AccessControll.doPrivileged(Native Method)
      at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
      at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
  Could not find the main class: Test.java. Program will exit.
  </code></pre>