title: Getting filesystem path of class being executed
body: <p>Is there any way to determine current filesystem location of executed class from the code of this class, in runtime, given that it's executed using <code>java</code> command? </p>
  
  <p>For example for following class:</p>
  
  <pre><code>public class MyClass{
   public static void main(String[] args){\
     new MyClass().doStuff();
   }
  
   private void doStufF(){
     String path = ... // what to do here?!
     System.out.println("Path of class being invoked: " + path);
   }
  
  }
  </code></pre>
  
  <p>Is there any way to get and print the correct path in filesystem of MyClass.class file just being invoked?</p>
  
  <p>Similarly, if I invoke jar file from <code>java -jar</code> command, is there any way to get a path of jar file from within classes inside that jar?</p>
  
  <p>P.S.:Please, <strong>do not make any assumptions about working directory</strong> from which <code>java</code> command is invoked!</p>