Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java user.home to return in local language

When I run System.getProperty("user.home") on turkish windows 7, I get "C:\Users\aaaa" even though "Users" folder does not exist in my computer (I have the turkish translation of "users"). How can I get the correct user.home information? Thank you

like image 485
artsince Avatar asked Jun 30 '10 10:06

artsince


2 Answers

Which version of Windows are you running? On Vista and above (2008, 2008R2, Windows7), the folder is called Users in the file system, irrespective of the current language. But Windows Explorer displays it in the language of the UI, "Benutzer" (German) in my case. You can check in a command window that the real name of this folder is Users.

like image 65
Frank Avatar answered Sep 28 '22 01:09

Frank


even though "Users" folder does not exist in my computer (I have the turkish translation of "users").

That's not true. You have the "Users" folder. Windows just automatically translates it when displaying it. But you have to use "Users" for filesystem paths, which is what user.home returns. The localized name is only relevant for displaying it to the user. I'm not sure how to get it from Java code.

Frankly, I think the whole concept of displaying different folder names to the user than what is actually present in the filesystem is a bizarre perversion.

like image 41
Michael Borgwardt Avatar answered Sep 28 '22 01:09

Michael Borgwardt