天蓬老师2017-04-17 15:52:47
The definition of this variable is different in different versions of java.
In java7 and previous versions, the jvm environment variable user.home is defined as the superior directory of the desktop folder in the windows system. The location of desktop is read from HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionExplorerShell FoldersDesktop in the registry, and its value is generally %userprofile%desktop. Therefore, its upper-level directory, user.home, is generally mapped to %userprofile%, that is, c:documents and settingsyourusername or c:usersyourusername. This is prone to bugs in win7 that are parsed into the %userprofile% string but not further parsed into a directory path: http://bugs.java.com/view_bug.do?bug_id=4787931.
So this problem has been fixed in java8, and user.home is directly mapped to the system %userprofile% variable, which is usually the user's home directory, that is, c:usersyourusername.
In summary, just treat this variable as the system environment variable userprofile:
Environment.GetEnvironmentVariable("userprofile");
or
Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);