Share this page 

Get the Windows "My Documents" pathTag(s): Environment

This value is stored in the registry and there is no easy way to get it with regular Java unless you execute an external utility, see this HowTo.

As an alternative, we can use a method provided by the JFileChooser class.

import javax.swing.JFileChooser;

public class GetMyDocuments {
  public static void main(String args[]) {
     JFileChooser fr = new JFileChooser();
     FileSystemView fw = fr.getFileSystemView();

See also Get Windows Special Folders (JNA)