title: Java ImageIO resource path
body: <p>I have a Java program that runs fine in Eclipse - when I export an executable jar file it gives me an exception.</p>
  
  <p>I know it is because I am giving it the wrong path but I do not know how to fix. I tried using <code>getClass().getResourceaAsStream()</code> (or sth. like that) but that did not work as well.</p>
  
  <p>The code I am using at the moment is the following:</p>
  
  <p>line 31:</p>
  
  <pre><code>BufferedImage image = ImageIO.read(new File("/src/res/loading.png"));
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/ROMSe.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ROMSe.png" alt="enter image description here"></a></p>
  
  <p><a href="https://i.stack.imgur.com/gDIqG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gDIqG.png" alt="enter image description here"></a><a href="https://i.stack.imgur.com/yqkCM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yqkCM.png" alt="enter image description here"></a></p>