title: Exception in thread "main" java.lang.NoClassDefFoundError: program (wrong name: program/Program)
body: <p>I wrote a program on my mac and compiled it via terminal:</p>
  
  <pre><code>cd user/desktop/Code/Program/src/program
  javac Program.java
  **java Program**
  </code></pre>
  
  <p>Then I get this error:</p>
  
  <pre><code>Exception in thread "main" java.lang.NoClassDefFoundError: Program (wrong name: program/Program)
      at java.lang.ClassLoader.defineClass1(Native Method)
      at java.lang.ClassLoader.defineClass(ClassLoader.java:791)
      at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
      at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
      at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
      at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
      at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
      at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
      at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:480)
  </code></pre>
  
  <p>Does anyone know how I can fix this?</p>
  
  <p>Source code:</p>
  
  <pre><code>package learning;
  
  public class Learning{
  
      public static void main(String[] args){
          String[] wordListOne = {"you are","I know","I eat"};
          String[] wordListTwo = {"a poo","a funny","a posh"};
          String[] wordListThree = {"Sandwich","person","object"};
  
          int oneLength = wordListOne.length;
          int twoLength = wordListTwo.length;
          int threeLength = wordListThree.length;
  
          int rand1 = (int) (Math.random() * oneLength);
          int rand2 = (int) (Math.random() * twoLength);
          int rand3 = (int) (Math.random() * threeLength);
  
          String phrase = wordListOne[rand1]+" "+wordListTwo[rand2]+" "+wordListThree[rand3];
  
          System.out.println(phrase);
      }
  }
  </code></pre>