title: Images cannot be found in .jar file
body: <p><strong>This question is edited to include everything asked. New picture links will be added below.</strong></p>
  
  <p>My program runs fine in NetBeans, and cannot load the program when running from its jar file, compiled by NetBeans. I'm compiling on Java 1.6_45, which is simply for compatibility, since this a school-oriented program, for older machines that hardly ever receive any upgrades or updates. </p>
  
  <p>Anyhow, because the program never loaded when I tried it as a .jar file, I was concerned and looked up manual ways to make the jar run. I tried the command prompt command
  java -jar PhysicsEquations.jar
  , which I copied straight into my Users folder so I wouldn't have to worry about classpaths.</p>
  
  <p>This is the error message I get (below, first link), an IllegalArgumentException. I'm not sure what to do, and I've researched for a couple of days now trying different things. I'm up for retrying anything though if it could be better explained.</p>
  
  <p>Here is the entire EquationImage class (just a couple lines, bear with me, please). In other code, all I do with it is call the constructor, such as <code>EquationImage fma = new EquationImage("fma.jpg");</code> and then use <code>setBounds(x,y,width,height);</code> to add it to a panel that's added to my CardLayout with all of the equations.</p>
  
  <pre><code>package physicsequations;
  ...
  public class EquationImage extends JPanel {
      public EquationImage() {
      }
  
      public EquationImage(String filename) {
          try {
              System.out.println(filename);
              imageBuffer = ImageIO.read(getClass().getResourceAsStream("images/" + filename));
          }
          catch(IOException e) {
              JOptionPane.showMessageDialog(null, "EquationImage could not find/load the file \n" + filename, "Error Message", JOptionPane.PLAIN_MESSAGE);
          }
      }
  
      @Override
      protected void paintComponent(Graphics graphics) {
          super.paintComponent(graphics);
          graphics.drawImage(imageBuffer, 0, 0, null);
      }
  
      private BufferedImage imageBuffer = null;
  }
  </code></pre>
  
  <p>As notable in the code, and the error message, the constructor does receive a filename. In NetBeans, the compiler is able to find all of the images correctly. However, in the jar that I get using 'Clean and Build', it can vary whether or not I actually see a JOptionPane with the error.</p>
  
  <p>I was asked to provide filepaths that I have for my code. </p>
  
  <p>In the project, I have the folder PhysicsEquations. PhysicsEquations has folders dist, build, nbproject, and src. PhysicsEquations also has files build, and manifest.mf. </p>
  
  <p>src has the folder physicsequations, the package that EquationImage is in.</p>
  
  <p>physicsequations then has five files and a folder 'images'. The files are Main, EquationPanel, EquationImage, BadInputException, and Variable.</p>
  
  <p>images has all of my pictures, including Physics.jpg, which is the icon I use in Main:</p>
  
  <pre><code>String imagePath = "physics.jpg";
  InputStream imgStream = Main.class.getResourceAsStream("images/" + imagePath);
  BufferedImage myImg = null;
  try {
      myImg = ImageIO.read(imgStream);
  }
  catch(IOException e) {
      JOptionPane.showMessageDialog(null, "The program has failed to load file physics.jpg from the source package.", "Error Message", JOptionPane.ERROR_MESSAGE);
  }
  setIconImage(myImg);
  </code></pre>
  
  <p>In the jar itself, I open up the jar and have 2 folders: META-INF and physicsequations. In the folder physicsequations, there are 101 class files, and a folder called images. That folder has all 17 of my pictures used in the project. Below is the text of the manifest.mf document in META-INF from the jar. (<strong>Can someone explain to me why it says 1.8? I have 1.6 in my project properties...</strong>)</p>
  
  <pre><code>Manifest-Version: 1.0
  Ant-Version: Apache Ant 1.9.4
  Created-By: 1.8.0_31-b13 (Oracle Corporation)
  Class-Path: 
  X-COMMENT: Main-Class will be added automatically by build
  Main-Class: physicsequations.Main
  
  http://i.stack.imgur.com/IqgzE.jpg
  http://i.stack.imgur.com/rHaDa.jpg
  http://i.stack.imgur.com/j5Npw.jpg
  http://i.stack.imgur.com/Yt2O3.jpg
  </code></pre>
  
  <p>I'm hoping all of the links will submit since it says I have limit with 10 rep.</p>