title: List files in a directory from a runnable jar
body: <p>So I've been trying for quite a while to deal with an issue I have after converting my java project(game) into a runnable jar. My issue has to do with the way I'm loading my resources. As I've read in many other answers that one possible way to deal with image loading for example when dealing with a runnable jar is to use <code>ImageIO.read(getClass().getResourceAsStream(path);</code>This works perfectly.</p>
  
  <p>But my issue is that in a particular folder I have 300 pngs I need to load and they way I've been dealing with this so far is by using a <code>File dir</code> object representing the directory and then iterating through all the files in that directory by using <code>dir.listFiles()</code>, extracting their path and loading them normally with <code>ImageIO</code>. The problem is that this method throws an exception when launching the jar.</p>
  
  <p>Although I could theoretically hard code every single image loading for all the 300 pngs I would like 
  to know if there is a way around this obstacle. </p>
  
  <p>Many thanks and sorry for the long post!</p>
  
  <p>Alex</p>
  
  <p>(Update) My project hierarchy in eclipse look like this:</p>
  
  <blockquote>
    <p>Game  // the project</p>
  </blockquote>
  
  <pre><code> &gt;src              //source code
        &gt;main        //main package
             &gt;loader // the loader file 
   &gt;res              // resources
        &gt;images      // the folder containing the 300pngs
  </code></pre>