title: Get location of JAR file
body: <p>I'm trying to get the location a Runnable JAR file is run from. 
  I tried doing</p>
  
  <pre><code>try {
      String path = new java.io.File(".").getCanonicalPath();
  } catch (IOException e) {
      e.printStackTrace();
  }
  </code></pre>
  
  <p>But that returns:</p>
  
  <pre><code>C:\Users\Kevin\Desktop/server/Server
  </code></pre>
  
  <p>while the JAR file is located at</p>
  
  <pre><code>C:\Users\Kevin\Desktop
  </code></pre>
  
  <p>I also tried doing</p>
  
  <pre><code>return new file(Server.class.getProtectionDomain().getCodeSource().getLocation().getPath());
  </code></pre>
  
  <p>But that returns:</p>
  
  <pre><code>C:\Users\Kevin\Desktop\server.jar/server/Server
  </code></pre>
  
  <p>So basicly I want the path of the JAR file without the filename and not the ClassPath.</p>
  
  <p>Any way of doing this?</p>