title: Cannot read resource from Jar File
body: <p>I am having trouble figuring out this problem and I have tried almost everything.</p>
  <p>I would like my program to read two resources from Jar File, and it will run fine through eclipse. However it gives nullpointer exception when I run the jar from command prompt.</p>
  <p>Structure:</p>
  <blockquote>
  <p>src/main/java/App.java</p>
  <p>src/main/resources/properties/application.properties</p>
  <p>src/main/resources/spring/applicationContext.xml</p>
  </blockquote>
  <p>Code:</p>
  <p>To read application.properties</p>
  <blockquote>
  <p>properties.load(App.class.getResourceAsStream(&quot;/properties/application.properties&quot;));</p>
  </blockquote>
  <p>To read applicationContext.xml</p>
  <blockquote>
  <p>context = new ClassPathXmlApplicationContext(&quot;/spring/applicationContext.xml&quot;);</p>
  </blockquote>
  <p>Error:</p>
  <blockquote>
  <p>Error while loading
  application.properties java.lang.NullPointerException</p>
  </blockquote>
  <p>What could I be doing wrong?</p>