<p>I've recently searched how I could get the application's directory in Java. I've finally found the answer but I've needed surprisingly long because searching for such a generic term isn't easy. I think it would be a good idea to compile a list of how to achieve this in multiple languages.</p>

<p>Feel free to up/downvote if you (don't) like the idea and <strong>please contribute</strong> if you like it.</p>

<h2>Clarification:</h2>

<p>There's a fine distinction between the <em>directory that contains the executable file</em> and the <em>current working directory</em> (given by <code>pwd</code> under Unix). I was originally interested in the former but feel free to post methods for determining the latter as well (clarifying which one you mean).</p>

In
Java
, there are two ways to find the application's path. One is to employ
```
System.getProperty
```
:
```
```
System.getProperty("user.dir");
```
```
Another possibility is the use of
```
java.io.File
```
:
```
```
new java.io.File("").getAbsolutePath();
```
```
Yet another possibilty uses reflection:
```
```
getClass().getProtectionDomain().getCodeSource().getLocation().getPath();
```
```