Returning the path to "My Documents" directory on Windows Platform

In Java is it possible to get the location (path) of the "My Documents" directory in Java. This directory has the ability of being located somewhere other than it's default on C:\. For instance it can be set to be located on a corporate IT drive for auto backup purposes. So whatever function I use needs to report back the absolute path to the "My Documents" actual location. A code snippet is not necessary if you can point me to the documentation to accomplish this. Thanks.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

try this:

String userHome = System.getProperty(:user.home");

//or user.dir please try both
sorry offcourse:
String userHome = System.getProperty("user.home");

Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

I know this works in NT-based systems for the default location, so hopefully this will give you an idea. There is a "java.home" environment variable (retrievable from System.getProperty( "java.home" )) that will point to the user's base directory. That would be c:\documents and settings\<username> in NT-based systems.

I think your best option in this case would be to pass the path to the "My Documents" directory in on the commandline:

java -Duser.document.dir="drive:\path\My Documents" my.package.MyClass

Then, you would be able retrieve it using System.getProperty( "user.document.dir" ).

I know this isn't the sure-fire answer you wanted, but I hope it will at least give you an idea.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Yeah. Everyone else is right. "user.home" not "java.home".
tk1016Author Commented:
Hi all,

thanks for answering...none of the above actually return the path to where "My Documents" is located if the system option to move that directory is exercised. The system can find it, but java still cannot. Another team member ended up doing some JNI so we could call the Windows Function directly.

Thanks...I have other questions though.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.