title: How to get src/main/resources path from Java
body: <p>I have some stuff under <code>src/main/resources</code> path.
  Specifically I have a folder with report templates called reports.</p>
  
  <p>I understand that when the application is deployed/run all files and folders under <code>src/main/resources</code> go to the classpath, namely my project's <code>WEB-INF/classes</code>.</p>
  
  <p>This means that a folder <code>WEB-INF/classes/reports</code> will be created in my server.</p>
  
  <p>Now I want to access my reports <strong>as paths</strong>, not as inputstream, because my reporting code in java supports a filepath and not an inputstream. So I have to be able to get the <code>WEB-INF/classes/reports</code> absolute path (or relative, I don't care as long as it is right).</p>
  
  <p>Reading some answers regarding similar questions, I have already tried the following things:</p>
  
  <ol>
  <li><p><code>getClass().getResource(".").getPath();</code> --> this returns the exact path of the class I am currently at in my classpath, namely: <code>C:\Tools\JBoss Application Server 7.1.1\standalone\deployments\myProject.war\WEB-INF\classes\aaa\bbb\ccc\ddd</code></p></li>
  <li><p><code>getClass().getClassLoader().getResource(".").getPath();</code> --> this returns: <code>C:\Tools\JBoss Application Server 7.1.1\modules\sun\jdk\main\service-loader-resources</code>, which is completely irrelevant.</p></li>
  </ol>
  
  <p>I want something to return <code>C:\Tools\JBoss Application Server 7.1.1\standalone\deployments\myProject.war\WEB-INF\classes</code></p>
  
  <p>If it is not possible, I will get the first path and go as many folders back as needed to reach classes folder.</p>
  
  <p>Thank you.</p>