How to run as administrator from java code(For mac osx)?
I am trying to run a command on my mac os with java code :-
Process p = Runtime.getRuntime().exec(command);
This is the command
sudo installer -pkg /Users/sumish/Desktop/aster.mpkg -target /Applications
When I run the command from terminal it prompts me for a administrator password
How can I d开发者_如何学Co this from my code?
I think your java
process should be started with privileges in order for you to fork and launch another process which requires administrator rights.
So, the JVM which runs the code containing Process p = Runtime.getRuntime().exec(command);
should be started using a sudo java
command.
精彩评论