Microsoft KB Archive/221206

= BUG: System.getProperty("user.home") Returns Java Home Directory =

Article ID: 221206

Article Last Modified on 10/20/2003

-

APPLIES TO


 * Microsoft Visual J++ 6.0 Standard Edition
 * Microsoft Java Virtual Machine

-



This article was previously published under Q221206



SYMPTOMS
According to the documentation, System.getProperty("user.home") should return a String containing the user's home directory. Instead, the Microsoft virtual machine (Microsoft VM) returns the Java home directory, which is also returned by a call to System.getProperty("java.home").



RESOLUTION
While there are no known pure Java workarounds, there are a couple of things to try using Win32 code. To get the user's home directory, you could do the following:
 * Use the USERPROFILE environment variable in Windows NT to determine the user's home directory by making a JDirect call to the Win32 API function GetEnvironmentVariable. (For Windows 9x users, require the user to set USERPROFILE on boot.)
 * Use Win32's GetWindowsDirectory and WFC's getUserName to find the user's home directory.
 * Use WFC's getUserName method to create a directory under "C:\A_KNOWN_DIRECTORY\[username]".



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.

Keywords: kbbug kbnofix kbdocfix kbfaq KB221206

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.