Access properties file in an executable jar
<p>My goal is to create an executable jar from Eclipse. I have an Eclipse project which runs fine with the structure below.</p>

<p><strong>My Eclipse project</strong></p>

<pre><code>src/main/java
-com.main
      -&gt;MyClass

src/main/resources
 -&gt;MyProps.properties
</code></pre>

<p><code>MyClass</code> is able to access <code>MyProps.properties</code> file successfully.</p>

<p>After I export the Eclipse project and create a runnable jar then my jar structure is like below.</p>

<p><strong>MyJar.jar</strong></p>

<pre><code>-com.main
  -&gt;MyClass

-resources
 -&gt;MyProps.properties
</code></pre>

<p>When I run the jar file it fails to access the properties file throwing a <code>NullPointerExeception</code>.</p>

<p><strong>My code</strong> </p>

<pre><code>InputStream input = MyClass.class.getClassLoader()
                           .getResourceAsStream("resources/MyProps.properties");
</code></pre>

<p>When I export my project as an executable jar file, I cannot access <code>MyProps.properties</code> anymore.</p>

<p>Can someone help me please?</p>