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.
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论