title: java.lang.IllegalArgumentException: input == null! when using ImageIO.read to load image as bufferedImage
body: <p>This is a question that has been asked like 100 times on this site, but I have looked at all of them and even though they all were solved, none of the solutions worked for me. </p>
  
  <p>Here's what my code looks like:</p>
  
  <pre><code>public Button1(Client client, String imgName) {
      this.client = client;   
  
      try {
          this.icon = ImageIO.read(this.getClass().getResourceAsStream("/resources/" + imgName));
      } catch (IOException e) {
          e.printStackTrace();
      }
  </code></pre>
  
  <p>When the code runs it results in the following error:</p>
  
  <pre><code>Exception in thread "main" java.lang.IllegalArgumentException: input == null!
  at javax.imageio.ImageIO.read(Unknown Source)
  </code></pre>
  
  <p>The string imgName is passed to the constructor from a child class and is the name of an image (e.g. image.png). I also have made sure that my resources folder is in the root of the project folder, and is included as a source folder in the eclipse project. I've also made sure that <code>System.getProperty("user.dir")</code> points to the correct location. I have also tried using getResource() instead of getResourceAsStream(), but it still does not work.</p>