United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-6519127 Vista: user.home property not set correctly
JDK-6519127 : Vista: user.home property not set correctly

Details
Type:
Bug
Submit Date:
2007-01-30
Status:
Closed
Updated Date:
2014-03-27
Project Name:
JDK
Resolved Date:
2013-01-23
Component:
core-libs
OS:
windows_vista
Sub-Component:
java.lang
CPU:
x86
Priority:
P4
Resolution:
Fixed
Affected Versions:
6
Fixed Versions:

Related Reports
Backport:
Duplicate:
Duplicate:
Duplicate:
Relates:

Sub Tasks

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
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.
                                     
2007-01-31
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....
                                     
2008-08-28
URL:   http://hg.openjdk.java.net/jdk8/tl/jdk/rev/01b36b400145
User:  uta
Date:  2013-01-23 11:10:48 +0000

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

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



Hardware and Software, Engineered to Work Together