title: How to reference a resource file correctly for JAR and Debugging?
body: <p>I have a nasty problem referencing resources when using a Maven project and Jar files...</p>
  
  <p>I have all my resources in a dedicated folder /src/main/resources which is part of the build path in Eclipse. Files are referenced using </p>
  
  <pre><code>getClass().getResource("/filename.txt")
  </code></pre>
  
  <p>This works fine in Eclipse but fails in the Jar file - there the resources are located in a folder directly below the jar's root...</p>
  
  <p>Does anyone know a 'best practice' to reference a file both in the JAR and (!) in Eclipse?</p>
  
  <p><b>Edit:</b>
  The problem is that while the resources actually are located in the JAR in a folder "resources" at the top level, the above method fails to find the file...</p>