title: How can my project access its "resources" directory both when run in Eclipse and from a Maven-packaged jar file?
body: <p>I'm working with Maven project in Eclipse (with help of m2e plugin). When I pack my project into jar-file (mvn install), all files from "resources" are located in the root of jar.</p>
  
  <p>Therefore, in my program I should use only bare file names:</p>
  
  <pre><code>File file = new File("foo.txt");
  </code></pre>
  
  <p>But when I build and run my project by Eclipse, I would have to use the relative path to the file:</p>
  
  <pre><code>File file = new File("src/main/resources/foo.txt");
  </code></pre>
  
  <p>What should I do to solve this problem? </p>