JDK-6519127 : Vista: user.home property not set correctly
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.lang
  • Affected Version: 6
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: windows_vista
  • CPU: x86
  • Submitted: 2007-01-30
  • Updated: 2023-09-18
  • Resolved: 2013-01-23
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8
8 b75Fixed
Related Reports
Duplicate :  
Duplicate :  
Duplicate :  
Relates :  
Relates :  
Description
FULL PRODUCT VERSION :
java version "1.6.0"
Java(TM) SE Runtime Environment (build 1.6.0-b105)
Java HotSpot(TM) Client VM (build 1.6.0-b105, mixed mode, sharing)

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.0.6000]

EXTRA RELEVANT SYSTEM CONFIGURATION :
Corporate computer part of a Windws NT domain.

A DESCRIPTION OF THE PROBLEM :
The system property user.home is wrong. If my login name is xxxx, the user.home directory should be c:\Users\xxxx on Vista. Java gets the user.name right, but the user.home is different: in my case it uses the domain guest account, which I have no clue how it gets to that! It might just be that it is the first directory found in C:\Users.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
1.6.0
xxxx
C:\Users\xxxx

ACTUAL -
1.6.0
xxxx
C:\Users\DGUEST

REPRODUCIBILITY :
This bug can be reproduced always.

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

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

CUSTOMER SUBMITTED WORKAROUND :
Force the user.home system property to the correct as a -Duser.home=... argument to the JVM.

Comments
Release note added to "Incompatibilities between JDK 8 and JDK 7" section of the JDK 8 release notes
27-03-2014

URL: http://hg.openjdk.java.net/jdk8/jdk8/jdk/rev/01b36b400145 User: lana Date: 2013-01-29 18:46:15 +0000
29-01-2013

URL: http://hg.openjdk.java.net/jdk8/tl/jdk/rev/01b36b400145 User: uta Date: 2013-01-23 11:10:48 +0000
23-01-2013

EVALUATION On a "fresh' installed Vista, the lookup mechansim just works fine (means your DESKTOP fold is under your "home" directory, which is the "normal" scenario). Thing goes wrong in cases you "tweak" the DESKTOP folder or as one reported when updated from XP2 and somehow the Windows register still remembers the "old" location of DESKTOP folder. The suggested approach of taking a look at USERPROFILE might be a solution, but might be too risky, consider someone just re-set that env to somewhere else....
28-08-2008

EVALUATION Currently we are looking at the registry key "DeskTop" in entry "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders" for HKEY_CURRENT_USER, kind of hacky. Will check the config of a vista when I have one installed.
31-01-2007