public static final String getHomeDir() {
    String homeDir = null;
    try {
      String os = System.getProperty("os.name").toLowerCase();
      try {
        if (os.startsWith("windows")) {
          // JRE prior to 1.5 cannot reliably determine USERPROFILE.
          // Return user.home and hope it's right.
          if (Integer.parseInt(System.getProperty("java.version").split("\\.")[1]) < 5) {
            try {
              homeDir = System.getProperty("user.home");
            } catch(java.security.AccessControlException e) {
              vlog.error("Cannot access user.home system property:" +
                         e.getMessage());
            }
          } else {
            homeDir = System.getenv("USERPROFILE");
          }
        } else {
          try {
            homeDir = FileSystemView.getFileSystemView().
                      getDefaultDirectory().getCanonicalPath();
          } catch(java.security.AccessControlException e) {
            vlog.error("Cannot access system property:" + e.getMessage());
          }
        }
      } catch(java.lang.Exception e) {
        e.printStackTrace();
      }
    } catch(java.security.AccessControlException e) {
      vlog.error("Cannot access os.name system property:" + e.getMessage());
    }

    return homeDir + getFileSeparator();
  }