Hello,

How to make JAR program run at system start up? The method mentioned in "How can I create entry for auto start my application on Mac" doesn't work.

asked 26 Mar, 14:25

Codename%20K's gravatar image

Codename K
246596371
accept rate: 50%


You can create a java launcher using <createJavaLaunchers> and then create a service using <createOSXService>

<postInstallationActionList>
   ...
    <createJavaLaunchers>
      <destination>${installdir}</destination>
      <javaLauncherList>
        <javaLauncher>
          <binaryName>sample</binaryName>
          <jarFile>${installdir}/sampleJavaApp.jar</jarFile>
        </javaLauncher>
      </javaLauncherList>
    </createJavaLaunchers>
 ...
     <createOSXService>
      <keepAlive>1</keepAlive>
      <program>${installdir}/sample.app/Contents/MacOS/installbuilder.sh</program>
      <programArguments>--service</programArguments>
      <serviceName>com.bitrock.sample</serviceName>
      <scope>user</scope>
      <username>daemon</username>
      <groupname>wheel</groupname>
    </createOSXService>
  ...
  </postInstallationActionList>

To delete the service you can use <deleteOsxServixe>:

 <preUninstallationActionList>
   ...
    <deleteOSXService>
        <serviceName>com.bitrock.sample</serviceName>
        <scope>system</scope>
    </deleteOSXService>
    ...
</preUninstallationActionList>
link

answered 30 Mar, 08:25

Michiel's gravatar image

Michiel ♦
82114
accept rate: 22%

Thank you. It worked perfectly.

(30 Mar, 14:08) Codename K
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×130
×92
×40
×7

Asked: 26 Mar, 14:25

Seen: 80 times

Last updated: 30 Mar, 14:08