簡體   English   中英

如何在啟動/登錄時使用Mac OS上的launchd運行Java Web Start程序?

[英]How do you run a Java Web Start program at startup/logon using launchd on Mac OS?

我花了一段時間才弄清楚,我還沒有在網上看到任何其他關於此的參考。

使用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會看到該程序退出並終止它生成的所有子進程。

不要試圖為javaws使用-wait開關。 這是行不通的。

因為-wait不起作用,所以無法使用KeepAlive設置。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM