title: Mule - how to access files in src/main/resources in Java class when running in Studio and Standalone?
body: <p>I have a Mule CE application that is using a Java component to transform a CSV file to XML. My Java class needs to access a flatpack XML file called <code>map.xml</code> - I have placed this in <code>src/main/resources</code>. My Java class is in <code>src/main/java</code>. I'm currently accessing the <code>map.xml</code> file in my Java class as follows:</p>
  
  <p><code>fr = new FileReader("src/main/resources/map.xml");</code> </p>
  
  <p>This works fine in Mule Studio, but when I try and run this application in Mule Standalone, I get the following error:</p>
  
  <p><code>java.io.FileNotFoundException: src/main/resources/map.xml (No such file or directory)</code></p>
  
  <p>Is there a way I can make this file path mutual so that it will work in both Studio and Standalone? I have also tried simply <code>fr = new FileReader("map.xml");</code> and this fails in Studio.</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>Through a combination of the answer from @Learner, and some info in <a href="https://stackoverflow.com/questions/17554085/how-to-create-a-file-in-src-main-resources">this</a> post, I've managed to find a solution to this problem. I've updated my Java class to the following and this has worked in both Studio and Standalone:</p>
  
  <pre><code>fr = new FileReader(MyClassName.class.getResource("/map.xml").getPath());
  </code></pre>
  
  <p><strong>UPDATE</strong></p>
  
  <p>How to retieve mule-app.properties file? If same then will it work onCloudHub as well.</p>