title: Proper method to find user's My Documents folder on Windows with Java?
body: <p>For whatever reason, I sometimes need to find the current user's My Documents folder on Windows in a Java program to read some files. But as far as I can tell, there is no way to do it that isn't severely flawed.</p>
  
  <p>The first wrong way: System.getProperty("user.home");<br>
  Why it won't work:</p>
  
  <ul>
  <li>It only returns the \username\ folder; I'd need to add "\Documents\" on to the end to get the Documents folder... and that only works in English.</li>
  <li><a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6519127" rel="noreferrer">Sun bugs 6519127</a> and 4787931. Java finds the user home folder on Windows by reading a deprecated registry key* to find the Desktop then taking the parent; this method has multiple known problems that will easily cause a completely wrong folder to be returned. The bugs are 3.75 years and 8 years old with no fix.</li>
  </ul>
  
  <p>The second wrong way: Using a registry-reading program to get the Personal folder of the user, which is My Documents (but i18n'd).<br>
  Why it won't work:<br>
  While it fixes the English-only problem, it's still using the same deprecated registry area, so the bugs still apply to it.</p>
  
  <p>The deprecated registry key says to use a native call (SHGetKnownFolderPath) which I obviously can't do from Java.</p>
  
  <p>The third wrong way:</p>
  
  <pre><code>JFileChooser fr = new JFileChooser();  
  FileSystemView fw = fr.getFileSystemView();  
  File documents = fw.getDefaultDirectory();
  </code></pre>
  
  <p>Why it won't work: It works great!<br>
  Except when it doesn't. While I had a program that used this open and running in the background, I opened a DirectX game (Fallout: New Vegas). The Java program immediately <em>terminated</em> with no stack trace. Always reproducible (for me on that game, and who knows what else). Couldn't find a Sun bug#.</p>
  
  <p>So is there any method to find a user's Documents folder, on Windows, from Java, that doesn't have known problems?</p>
  
  <p>(This is a nice big question.)</p>
  
  <p>*(The key is "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders")</p>