我花了一段时间才弄清楚,我还没有在网上看到任何其他关于此的参考资料。
问问题
1893 次
1 回答
4
使用 vi 在如下路径创建文件:
~/Library/LaunchAgents/com.mycompany.myprogram.plist
该文件应包含以下内容:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC -//Apple Computer//DTD PLIST 1.0//EN
http://www.apple.com/DTDs/PropertyList-1.0.dtd >
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.docuvantage.dvdesktop</string>
<key>ProgramArguments</key>
<array>
<string>/usr/bin/javaws</string>
<string>-Xnosplash</string>
<string>http://www.mycompany.com/pub/myprogram.jnlp</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>AbandonProcessGroup</key>
<true/>
</dict>
</plist>
像这样验证文件语法:
plutil -lint ~/Library/LaunchAgents/com.mycompany.myprogram.plist
测试配置:
launchctl load ~/Library/LaunchAgents/com.mycompany.myprogram.plist
卸载以便您可以再次测试:
launchctl unload ~/Library/LaunchAgents/com.mycompany.myprogram.plist
您必须将 AbandonProcessGroup 设置为 true 以防止 launchd 杀死您的应用程序。javaws 可执行文件分叉几次并创建子进程,然后 javaws 退出。默认情况下,launchd 会看到程序退出并杀死它产生的所有子进程。
不要费心尝试使用-wait
javaws 的开关。这没用。
因为-wait
不起作用,您无法使用该KeepAlive
设置。
于 2013-07-18T20:16:08.933 回答