title: JAVA: including files in jar and how to access them
body: <p>I need to include some image files in the exported jar file, I searched a bit and found <a href="https://stackoverflow.com/a/18092011">this</a> and <a href="https://stackoverflow.com/a/1464366">this</a> answers but I can't get it to work.</p>
  
  <p>so my file structure is:</p>
  
  <pre><code>root
  -assets
  --clean.png
  -src
  ...
  </code></pre>
  
  <p>I added the assets folder to the build path as suggested but if I unzip the jar the files are not in the assets folder but in the root.</p>
  
  <p>I tried the following codes:</p>
  
  <pre><code>InputStream i = getClass().getResourceAsStream("assets/clean.png");
  InputStream i = getClass().getResourceAsStream("/assets/clean.png");
  InputStream i = getClass().getResourceAsStream("clean.png");
  InputStream i = getClass().getResourceAsStream("/clean.png");
  </code></pre>
  
  <p>but they none of them work, <code>i</code> is <code>null</code>. What I'm missing?</p>
  
  <p>I'm using Maven</p>