osx - How to install a .pkg from Java Runtime? -


i automating installation of .pkg file in mac os x using java , have command bash console:

echo 'control123' | sudo -s installer -pkg /users/george/downloads/mypackage.pkg -target / 

i executing command java runtime:

runtime.getruntime().exec("echo 'control123' | sudo -s installer -pkg /users/george/downloads/mypackage.pkg -target /"); 

but package not installed, if execute command in bash console. works normally.

you shouldn't assume user has root privileges, , it's better idea launch installer user can authorize , update application there. if makes sense, it's possible launch .pkg way, sudo not required:

string userhome = system.getproperty( "user.home" ); string cmdstring = ("open " + userhome + "/downloads/mypackage.pkg"); 

i'm not sure why need echo 'control123', might need echo separately.


Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -