launchd: Managing a Java Jar

蓝咒 提交于 2019-12-11 03:44:29

问题


I have the following launchd configuration (stored in acme.plist) which I load and start using launchctl load acme.plist and launchctl start acme.plist respectively.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>com.acme</string>

    <key>ProgramArguments</key>
    <array>
        <string>/usr/bin/java</string>
        <string>-jar /usr/local/acme/acme-latest.jar</string>
    </array>

    <key>StandardErrorPath</key>
    <string>/tmp/acme-error</string>
</dict>
</plist>

Whenever I try to run it, I get the following in /tmp/acme-error:

Unrecognized option: -jar /usr/local/acme/acme-latest.jar
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.

Yet I have absolutely no problems when running from bash. Any ideas?


回答1:


You should change your config like so:

<key>ProgramArguments</key>
<array>
    <string>/usr/bin/java</string>
    <string>-jar</string>
    <string>/usr/local/acme/acme-latest.jar</string>
</array>


来源:https://stackoverflow.com/questions/32927956/launchd-managing-a-java-jar

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!