Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6590456

System.getProperty("user.home") returns wrong directory (win)

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P5 P5
    • 8
    • 6
    • core-libs
    • x86
    • windows_xp

      FULL PRODUCT VERSION :
      java version "1.6.0_01"
      Java(TM) SE Runtime Environment (build 1.6.0_01-b06)
      Java HotSpot(TM) Client VM (build 1.6.0_01-b06, mixed mode, sharing)

      ADDITIONAL OS VERSION INFORMATION :
      any Windows of the NT branch I guess

      EXTRA RELEVANT SYSTEM CONFIGURATION :
      my "Desktop" and "My Documents" folders are not in the default location

      A DESCRIPTION OF THE PROBLEM :
      Instead of returning something useful like %USERDATA% or even something better like %APPDATA%\Java the function returns something weird I can't even express with system variables.

      It returns the parent directory of "My Documents" or "Desktop" which doesn't even have to do anything with the user.

      My example: (where DaS means "Documents and Settings"):

      C:\DaS\user <-- my user profile folder
      C:\DaS\user\Application Data\Java <-- a good location for user.home

      D:\ <-- this is what user.home returns
      D:\My Documents <-- my "My Documents" folder
      D:\Desktop <-- my "Desktop" folder

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      - change My Documents and Desktop folders
      - call System.getProperty("user.home")

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      "%USERPROFILE%" or even "%APPDATA%\Java"
      ACTUAL -
      "'My Documents'\.." or "'Desktop'\.."

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      public class Userhome {
        public static void main(String[] args) {
          System.out.println(System.getProperty("user.home"));
        }
      }

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      getting the real directory from the registry or environmental variables

            uta Alexey Utkin (Inactive)
            ndcosta Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: