title: Use path of source in a scala script file
body: <p>I am looking for a way to use the full path of the *.scala file that is executed by</p>
  
  <pre><code>scala /path/to/file/file.scala 
  </code></pre>
  
  <p>The reason is that within my script I would like to use paths, which are relative to the location where file.scala is saved. So, say I want to call /path/to/file/file_second.scala from inside of file.scala while calling file.scala by</p>
  
  <pre><code>scala ./to./file/file.scala 
  </code></pre>
  
  <p>as the directory I invoked scala from is /path (i.e. what System.getProperty("user.dir") would return). All I know priori is that file_second.scala is in the same directory as file.scala without actually knowing the full path.</p>
  
  <p>I have tried. among others, getClass.getResource("").split(":")(1), but this will either 
  return /path/./ or /tmp/scala.tmp/</p>
  
  <p>I guess there must be a clean solution as scala -savecompiled will create a *.jar at exactly that directory I want to work on, but I just cannot figure out how...  :/</p>
  
  <p>Many thanks for any help.</p>