开发者

Is the system property user.home reliable in the current version of Java?

I need to know if it works correctly for windows (xp, vista/7), mac and some flavors of linux.

I know it's been discussed a开发者_如何学C lot on this site but:

  • bugs.sun.com is not working atm, or it has changed ...
  • I'm looking for recent developments

Thanks!


I definitely saw it working on XP and Win7 and all flavors of Linux I tried. If you wish to test it on specific version of linux I'd recommend you to find VM image for this version and try there.

What probably can be a problem is if current user does not have a home directory at all. I know it is possible but unfortunately I do not have such user account available right now to try this.


I have heard no word to the effect that it does not work.

To test it locally, I visited property applet showing java.version, os.name, os.version, user.home

Which returns the following results.

Name    Value
java.version    1.6.0_26
os.name Windows 7
os.version  6.1
user.home   C:\Users\Andrew

That information is correct.


It is working correctly.

But don't forget that it can always be overridden when starting the JVM:

java -Duser.home=/some/other/home MainClass
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜