3

I have a java application built with Eclipse, for Mac OS X. This app is installed via a .pkg file and supposed to be daemonized. Everything works fine, with Macbooks (Pro, Retina), but with the iMac I work on, when the application launches, i have an icon on the Dock, as you can see on the following link.

I have already tried the solution in this topic: stackoverflow.com/a/620950/3641679 but it didn't work (I still have the Dock icon). Currently the Info.plist looks like this.

What can I do?

Thank you for the time you'll be taking to help me.

Information (assuming the app name is testapp)

  • I stop or start the daemon using launchctl start/stop
  • When I double click on the executable (in testapp.app/Contents/MacOs/testapp) i have the testapp.app in the Dock (with the icon file specified in the Info.plist). Here is a screenshot res.cloudinary.com/doit0eqlo/image/upload/v1400750376/app_k3adzh.png
  • Sorry for some links, I must have 10 reputation to post more than 2 links.
hippietrail
  • 15,848
  • 18
  • 99
  • 158

2 Answers2

3

So, I finally found the solution! The solution is in several steps.

Step 1: Editing the Info.plist

I had to add the LSBackgroundOnly key. It is a string and has to be set to 1.

As said in the Apple Documentation :

LSBackgroundOnly

specifies whether this app runs only in the background. If this key exists and is set to “1”, Launch Services runs the app in the background only.

Information:

Although the documentation specifies this key is a boolean, setting it to a string with the value 1 in it does the trick.

To do so:

  1. Go to your app's folder

  2. Go into the .app's folder then the Contents one (eg. /Applications/test.app/Contents)

  3. Open the Info.plist with any text editor you want (SublimeText, TextEdit,Xcode, etc.)

  4. Add the following lines before the closing dict tag (</dict>)

<key>LSBackgroundOnly</key>

<string>1</string>

Save everything.

Step 2: Edit the appname.ini

Initially I only did the part 1, so it wasn't enough. I found the solution in this question.

The file is in the 'Contents/MacOs' folder inside your application's .app (e.g /Applications/testapp.app/Contents/MacOs/testapp.ini).

  1. Open the .ini file (with any text editor you want).

  2. Before the -vmargs line, add the following line: -nosplash

  3. After the -vmargs line, add the following two lines:

    -Xdock:hidden
    -Dapple.awt.UIElement=false

Save the file, and now you can launch the app: it shouldn't be any icon neither in the Dock nor in the 'Force Quit' window, but your app should be running in the background.

Hope this helps,

Community
  • 1
  • 1
  • I'm trying to do what you explained above but hI have to issues, one is overtime I edit to add: LSBackgroundOnly1 in info.plist and I save/close/reopen the app it says the app is damaged download again. The second thing is I don't have any ini file in contents/macOs/ I only have a script executable file with a terminal icon and nothing more. – Alfro Feb 12 '16 at 14:16
  • Sorry I totally forgot about this account! Did you manage to get it done? This reminds me of some bad things lol (just as an information, I gave up java few months later) – desert aibō Apr 20 '16 at 14:44
2

Add this to your info.plist: -

<key>LSUIElement</key>
<true/>

Note that the value here is set to 'true' and not 1

As the Apple docs state: -

Specifies whether the app is an agent app, that is, an app that should not appear in the Dock or Force Quit window. See “LSUIElement” for details.

TheDarkKnight
  • 27,181
  • 6
  • 55
  • 85
  • In the plist screenshot I have provided, you can see that this option is already included in the **.plist**... Something bugs me: in the Apple doc, the LSUIElement is a String, but you have put a boolean... Which one should I put? And I forgot to mention it, but I tested with the boolean too... – desert aibō May 22 '14 at 09:53
  • Sorry for the double post: I've just tried with the boolean, but still, no luck. This is my [.plist](http://res.cloudinary.com/doit0eqlo/image/upload/v1400753348/Capture_d_%C3%A9cran_2014-05-22_%C3%A0_12_04_25_-_copie_usj7aa.png) – desert aibō May 22 '14 at 10:06
  • I originally used the integer '1', which didn't work for me, but the boolean value true does. Does your java app launch its own executable, or is it a java package that is associated with the java runtime? If the latter, I suspect this is the problem as you're targeting the jar, not the runtime. – TheDarkKnight May 22 '14 at 10:29
  • I think the app launches its own executable, but how can I know for sure? All I know is that I have a folder in /Applications, with the **.app** folder in it, and the executable in the **.app/Contents/MacOs/** folder. The thing that bugs me, is that this problem occurs **only** on the **iMac** I'm working on, not on my personal **Macbook Pro** or some of my friends **Macbook Pros and Retinas**. I suspect a problem relative to the computer's **family** (maybe targeting only iMacs, or something like that), but I don't know for sure... – desert aibō May 22 '14 at 11:10
  • Sorry, I'm not sure why that would be. I've up-voted the question, so hopefully it will get more interest. – TheDarkKnight May 22 '14 at 12:27
  • 1
    I will try to find some other informations on the web, and post it here. Thank you for your help and directions! – desert aibō May 22 '14 at 13:52