How I can save file generated by java application in folder with root access?
Share
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.
The straight forward way to do that is to run your application as the root user.
Another solution is to ask to the user the root password. To do that, you have to ask the “su” command of your system. Be careful, your user must have the “wheel” group. Or, you can use sudo (make sure that sudo is installed and configured for the current user).
As caarlos0 said in the comments, you can use “kdesu” or “gtksu/gksudo” if you prefer.
Of course, your application is not portable ! On windows, there’s no “su”, “sudo”, etc.