Regex Rookie
Regex Rookie

Reputation: 10662

How to determine value of user.home without writing a program?

In a Windows XP system, is there a way to determine the current value of Java's user.home system property without having to write sample program like this?

i.e. from the command line or control panel or registry, etc.?

Upvotes: 4

Views: 5111

Answers (2)

x4u
x4u

Reputation: 14077

If you need to find the exact value that will be returned for user.home in a java program when it is run under the same user account you should actually run a java program to obtain the value. There is no guaranteed stable mapping to anything else on Windows for this propery and the mapping that is currently used is wrong and it's not unlikely that it will be changed eventually.

This bug entry describes how user.home actually gets it's value currently and discusses several alternatives that might be more appropriate: https://bugs.java.com/bugdatabase/view_bug?bug_id=4787931

Upvotes: 5

Peter Lawrey
Peter Lawrey

Reputation: 533520

To find the user's home directory without running a Java program you can ...

Under windows you need to look at %HOMEDRIVE% and %HOMEPATH%

Under Linux you can use $HOME

Upvotes: 2

Related Questions