<p>I want to bring up a file dialog in Java that defaults to the application installation directory.</p>

<p>What's the best way to get that information programmatically?</p>

[{'answer_id': 28454, 'author': 'Rich Lawrence', 'author_id': 1281, 'author_profile': 'https://Stackoverflow.com/users/1281', 'pm_score': 4, 'selected': True, 'text': '<pre><code>System.getProperty("user.dir") \n</code></pre>\n\n<p>gets the directory the Java VM was started from.</p>\n'}, {'answer_id': 28726, 'author': 'McDowell', 'author_id': 304, 'author_profile': 'https://Stackoverflow.com/users/304', 'pm_score': 2, 'selected': False, 'text': '<pre><code>System.getProperty("user.dir");\n</code></pre>\n\n<p>The above method gets the user\'s working directory when the application was launched. This is fine if the application is launched by a script or shortcut that ensures that this is the case.</p>\n\n<p>However, if the app is launched from somewhere else (entirely possible if the command line is used), then the return value will be wherever the user was when they launched the app.</p>\n\n<p>A more reliable method is to <a href="http://illegalargumentexception.blogspot.com/2008/04/java-finding-application-directory.html" rel="nofollow noreferrer">work out the application install directory using ClassLoaders</a>.</p>\n'}]
['https://Stackoverflow.com/questions/28428', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1288/']