lirong
asked on
Changing running permission to Root
Hi
I want to write a simpe Java application that has a Root permission (like modifying the /etc/hosts file).
I want to run this application with a X user that that user will have abilities to modify the /etc/hosts file.
Is it possible to do that in Java ?
I know that in C,C++ I can do that.
Thanks,
Liron
I want to write a simpe Java application that has a Root permission (like modifying the /etc/hosts file).
I want to run this application with a X user that that user will have abilities to modify the /etc/hosts file.
Is it possible to do that in Java ?
I know that in C,C++ I can do that.
Thanks,
Liron
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
sudo your-java-app
ASKER
I didn't followed you.
Let's say that I have a application called: My.class
This application needs to execute the command "mv /etc/hosts /etc/hosts.sav"
I'm running this application under user: lirong.
In order to execute the move, I need to execute it in a root permission.
How do I do that ?
Let's say that I have a application called: My.class
This application needs to execute the command "mv /etc/hosts /etc/hosts.sav"
I'm running this application under user: lirong.
In order to execute the move, I need to execute it in a root permission.
How do I do that ?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
The above isn't correct.
Please help !!!
Please help !!!
what is wrong?
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
Recommendation: Split between csar and ahoffman
Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
DominicCronin
EE Cleanup Volunteer
I will leave a recommendation in the Cleanup topic area that this question is:
Recommendation: Split between csar and ahoffman
Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
DominicCronin
EE Cleanup Volunteer
current update:
java.lang.Runtime.exec("su root -c "mv /etc/hosts /etc/hosts.sav")
java.lang.Runtime.exec("su