title: Packages in Java
body: <p>It's my first time using packages in Java, and I'm not sure where I went wrong. I'm trying to make a Tetris game. Here's part of my code:</p>
  
  <pre><code>package mytetris;
  
  import javax.swing.*;
  import java.awt.*;
  
  public class Tetris extends JFrame {
  
      // class constructor
      public Tetris() {
          super("Tetris");
          this.setSize(400, 600);
          this.setDefaultCloseOperation(EXIT_ON_CLOSE);
  
          // just started, haven't really done anything
  
          this.setVisible(true);
      }
  
      public static void main(String[] args) {
          Tetris myTetris = new Tetris();
      }
  }
  </code></pre>
  
  <p>I then compiled it using <code>javac Tetris.java</code> and then I tried running it using <code>java Tetris</code>, this is what the terminal gave me:</p>
  
  <pre><code>Exception in thread "main" java.lang.NoClassDefFoundError: Tetris (wrong name: mytetris/Tetris)
      at java.lang.ClassLoader.defineClass1(Native Method)
      at java.lang.ClassLoader.defineClassCond(ClassLoader.java:637)
      at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
      at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
      at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
      at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
      at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
      at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
  </code></pre>