title: How to access static resources in jar (that correspond to src/main/resources folder)?
body: <p>I have a <a href="https://spark.apache.org/streaming/" rel="nofollow">Spark Streaming</a> application built with Maven (as jar) and deployed with the <code>spark-submit</code> script. The application project layout follows the standard directory layout:</p>
  
  <pre><code>myApp
      src
          main
              scala
                  com.mycompany.package
                        MyApp.scala
                        DoSomething.scala
                        ...
              resources
                  aPerlScript.pl
                   ...
          test
             scala
                  com.mycompany.package
                        MyAppTest.scala
                        ...
          target
             ...
  pom.xml
  </code></pre>
  
  <p>In the <code>DoSomething.scala</code> object I have a method (let's call it <code>doSomething()</code>) that tries to execute a Perl script -- <code>aPerlScript.pl</code> (from the <code>resources</code> folder) -- using <code>scala.sys.process.Process</code> and passing two arguments to the script (the first one is the absolute path to a binary file used as input, the second one is the path/name of the produced output file). I call then <code>DoSomething.doSomething()</code>.</p>
  
  <p>The issue is that I was not able to access the script, not with absolute paths, relative paths, getClass.getClassLoader.getResource, getClass.getResource, I have specified the resources folder in my <code>pom.xml</code>. None of my attempts succeeded. I don't know how to find the stuff I put in src/main/resources. </p>
  
  <p>I will appreciate any help.</p>
  
  <p><strong>SIDE NOTES:</strong></p>
  
  <ul>
  <li>I use an external Process instead of a Spark pipe because, at this step of my workflow, I must handle binary files as input and output.</li>
  <li>I'm using Spark-streaming 1.1.0, Scala 2.10.4 and Java 7. I build the jar with "Maven install" from within Eclipse (Kepler)</li>
  <li>When I use the <code>getClass.getClassLoader.getResource</code> "standard" method to access resources I find that the actual classpath is the <code>spark-submit</code> script's one.</li>
  </ul>