今天我需要你的帮助:x我看到很多答案,但从来没有完整..
我想用另一个启动我的java应用程序
<code>Runtime.getRuntime().exec("my command");
</code>
在MAC OS X上.然后我发现命令:
<code>#!/bin/sh osascript -e "do shell script "$*" with administrator privileges" </code>
我在这个脚本中有什么要改变来运行我的应用程序,就像在linux上一样:
<code>Runtime.getRuntime().exec("gksudo java -jar myjar");
</code>
我想拥有
<code>Runtime.getRuntime().exec("osascript -e "do shell script \"$*\" with administrator privileges");
</code>
但这可能吗?谢谢你anwser:/
解决方法:
从Java调用osascriptWrapper.sh脚本:
<code>Runtime.getRuntime().exec("/path/to/osascriptWrapper.sh myjar.jar");
</code>
将osascriptWrapper.sh定义为:
<code>#!/bin/bash osascript -e "do shell script "/path2/to2/runJar.sh $*" with administrator privileges" </code>
和runJar.sh:
<code>#!/bin/bash java -jar $* </code>
【说明】:本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:254677821)!