VMware Cloud Community
CodenameK
Contributor
Contributor

MAC OS Sierra - How to run the JAR program at system start up (part 2)?

Hello,


This is based on this question. I used the <createOSXService> method to set the Java launcher app to run at startup. It does not run the Java launcher at startup. However, when you enter the ' launchctl list'  command in the Terminal it shows as running. But it is not starting at startup?

Labels (1)
0 Kudos
4 Replies
AnonymousDefaul
Enthusiast
Enthusiast

Hi,

The following section in our docs describe how to add an application to the system startup.

https://installbuilder.bitrock.com/docs/installbuilder-userguide.html#_adding_an_application_to_the_...

Hope it helps,

Michiel D'Hont

0 Kudos
CodenameK
Contributor
Contributor

I added this code,

<writeFile>     <path>${system_temp_directory}/your.plist</path>     <encoding>utf-8</encoding>     <text><![CDATA[ <plist version= or ' 1.0 or ' >   <dict>     <key>Label</key>     <string>com.myapp1.myapp2</string>     <key>ProgramArguments</key>     <array>       <string>/Applications/myapp.app</string>     </array>     <key>KeepAlive</key>     <true/>     <key>Hide</key>     <true/>     <key>RunAtLoad</key>     <true/>   </dict> </plist> ]]></text>   </writeFile>

But the InstallBuilder change it to this,

<writeFile>
    <encoding>utf-8</encoding>
    <path>${system_temp_directory}/your.plist</path>
    <text>
&lt;plist version= or ' 1.0 or ' &gt;
  &lt;dict&gt;
    &lt;key&gt;Label&lt;/key&gt;
    &lt;string&gt;com.myapp1.myapp2&lt;/string&gt;
    &lt;key&gt;ProgramArguments&lt;/key&gt;
    &lt;array&gt;
      &lt;string&gt;/Applications/myapp.app&lt;/string&gt;
    &lt;/array&gt;
    &lt;key&gt;KeepAlive&lt;/key&gt;
    &lt;true/&gt;
    &lt;key&gt;Hide&lt;/key&gt;
    &lt;true/&gt;
    &lt;key&gt;RunAtLoad&lt;/key&gt;
    &lt;true/&gt;
  &lt;/dict&gt;
&lt;/plist&gt;
</text>
</writeFile>

Also this did not run the Java Launcher  or ' myapp.app or '  at startup.

0 Kudos
AnonymousDefaul
Enthusiast
Enthusiast

Hi,

When using CDATA with the InstallBuilder GUI the inner XML is encoded to ensure it displays correctly. Regarding the Launcher not starting, could you change the path in the plist to the following and check if that does work?

<path>${user_home_directory}/Library/LaunchAgents/your.plist</path>

Regards,

Michiel D'Hont

0 Kudos
CodenameK
Contributor
Contributor

This worked. Thanks. This is the full code,


    <writeFile>
        <abortOnError>0</abortOnError>
        <encoding>utf-8</encoding>
        <path>${system_temp_directory}/your.plist</path>
        <show>0</show>
        <text>
&lt;plist version= or ' 1.0 or ' &gt;
  &lt;dict&gt;
    &lt;key&gt;Label&lt;/key&gt;
    &lt;string&gt;plistName&lt;/string&gt;
    &lt;key&gt;ProgramArguments&lt;/key&gt;
    &lt;array&gt;
      &lt;string&gt;/Applications/myapp.app/Contents/MacOS/myapp&lt;/string&gt;
    &lt;/array&gt;
    &lt;key&gt;Hide&lt;/key&gt;
    &lt;true/&gt;
    &lt;key&gt;RunAtLoad&lt;/key&gt;
    &lt;true/&gt;
  &lt;/dict&gt;
&lt;/plist&gt;
</text>
    </writeFile>
    <copyFile>
        <abortOnError>0</abortOnError>
        <destination>${user_home_directory}/Library/LaunchAgents/plistName.plist</destination>
        <origin>${system_temp_directory}/your.plist</origin>
        <show>0</show>
    </copyFile>

0 Kudos