I need to find my documents path using Java. The following code doesn’t give me “accurate” loation
System.getProperty("user.home");
What should be the other way around?
P.S:
I don’t want to use the JFileChooser Dirty trick.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can get it using a registry query, no need for JNA or admin rights for that.
Obviously this will fail on anything other than Windows, and I am not certain whether this works for Windows XP.
EDIT:
Put this in a working sequence of code:
Note this will lock the process until “reg query” is done, which might cause trouble dependeing on what you are doing.