title: How to get Path to resource folder in jar file
body: <p>I have a Spring Boot 2.5.4 application using Java 11.
  Running in my IDE the following code is fine:</p>
  <pre><code>Path directory = Paths.get(&quot;src/main/resources&quot;);
  log.info(&quot;PATH: &quot; + directory.toAbsolutePath());
  </code></pre>
  <p>But if I build a jar file with Maven the directory does not exist.
  Which String can I use in Paths.get to have a proper Path instance pointing to resources folder in my Spring project?</p>
  <hr />
  <p>Based on first comments I tried this:</p>
  <pre><code>var loader = ClassLoader.getSystemClassLoader();
  // &quot;templates&quot; is directory in &quot;src/main/resources&quot;
  var resDir = loader.getResource(&quot;templates&quot;);
  Path directory = Path.of(resDir.toURI());
  </code></pre>
  <p>This is again working in my IDE, but in jar file I get a <code>NullPointerException</code> in <code>Path.of(resDir.toURI())</code>.</p>