Question

We've got a customer who runs its Windows 7 installations with user profiles stored on a Windows Server on the intranet (it's called "terminal server environment" or something like that I think...).

Now I have some problems in Java regarding these "external" user profiles.

I am storing some settings in a folder in the users home folder (Windows: C:\Users\username\, Mac: /Users/username/). Because the app is cross-platform I don't use the windows environment variable %USERPROFILE% in Jave but the native Java property user.home.

However, this is what windows CMD says for the %USERPROFILE% variable:

>echo %USERPROFILE%
C:\Users\vvw\

And this is what I get in Java:

>System.getProperty("user.home")
C:\windows\system32\config\systemprofile\

Why does the Java property user.home defaults to this strange directory?

And what would be the best way to get to correct user home dir in Java for both Mac and Windows?


Update: Re-installing java and rebooting helped. However, it's good to know that this is also tracked as a bug in the Java Bug Database and this will be fixed in Java 8.

Was it helpful?

Solution

Read this article, someone there has the same problem.

Because you didn't say, that there are no problems on the mac, execute your code on other windows machines. Maybe something is wrong with your developer machine.

The directory C:\windows\system32\config\systemprofile\ looks like the user directory of the user SYSTEM, but I'm not sure. That could mean, that java is running under the user SYSTEM.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top