title: Why can't I getImage()?
body: <p>I am having somewhat of an issue getting an image from another class.  I have never had this problem before. Can someone please point me in the right direction.</p>
  
  <pre><code>package main;
  
  import java.awt.Color;
  import java.awt.DisplayMode;
  import java.awt.Graphics;
  import java.awt.GraphicsDevice;
  import java.awt.GraphicsEnvironment;
  import java.awt.Image;
  
  import javax.swing.ImageIcon;
  import javax.swing.JFrame;
  
  public class Main extends JFrame {
  
      public static Character character;
  
      static GraphicsEnvironment graphicsEnvironment;
      static GraphicsDevice graphicsDevice;
      static DisplayMode displayMode;
  
      private Image i;
  
      public static void main(String[] args) {
          displayMode = new DisplayMode(1280, 720, 16, DisplayMode.REFRESH_RATE_UNKNOWN);
          graphicsEnvironment = GraphicsEnvironment.getLocalGraphicsEnvironment();
          graphicsDevice = graphicsEnvironment.getDefaultScreenDevice();
  
          Main m = new Main();
          m.run();
      }
  
      public void run() {
          setUndecorated(true);
          setResizable(false);
  
          graphicsDevice.setFullScreenWindow(this);
  
          try {
              graphicsDevice.setDisplayMode(displayMode);
          } catch (Exception e) {
          }
      }
  
      public void paint(Graphics g) {
          g.setColor(Color.cyan);
          g.fillRect(0, 0, displayMode.getWidth(), displayMode.getHeight());
          i = character.getImage();
          g.drawImage(i, 100, 100, this);
      }
  }
  </code></pre>
  
  <hr>
  
  <pre><code>package main;
  
  import java.awt.Image;
  import javax.swing.ImageIcon;
  
  public class Character {
      private Image i;
  
      public Image getImage() {
          i = new ImageIcon(this.getClass().getResource("/raw/images/player1.png")).getImage();
          return i;
      }
  }
  </code></pre>
  
  <hr>
  
  <pre><code>Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
  at main.Main.paint(Main.java:52)
  </code></pre>
  
  <hr>
  
  <p>It says that the error is <code>i = character.getImage();</code></p>
  
  <p>I have done this plenty of times when making applets, this if the first time I am trying a fullscreen game</p>