Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

launchd: Managing a Java Jar

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?

like image 413
abhillman Avatar asked Mar 15 '23 14:03

abhillman


1 Answers

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>
like image 129
cool Avatar answered Mar 20 '23 16:03

cool