Make an OSX application package for a Java program without using the user interface in the Dock while the application is running

I tried to create my first OSX application package for a Java application today. It works, but there is one problem, and I could not find any solution for this.

A Java application is a web server without a user interface. What happens when I run the application package is the following:

  • The application icon bounces several times in the dock and then disappears (I think because the graphical interface is not displayed?).
  • However, the application is still working. A web server is available, and I see the running application in Activity Monitor and stop it there.

The main goal of this application package is to provide a demo application for people who are interested in trying a server - without any settings, etc.

The application should remain in the Dock, and users should be able to close (stop) the server in the Dock.

I assume this can be configured in Info.plist in some way, but has no experience with it. Or maybe there is something else I can do to achieve the desired behavior?

Thanks for any ideas or tips.

+4
source share
1 answer

I found the answer to this problem today:

I did not notice it when copying configuration information to the Apple Jar Bundler, but I had it in the VMOptions parameter (Info.plist file):

<key>Java</key> <dict> [...] <key>VMOptions</key> <string>-Djava.awt.headless=true</string> [...] </dict> 

Passing -Djava.awt.headless=true to the Java virtual machine was a problem. After deleting this parameter, the application behaved the way I wanted. It does not have a window, but there is a simple menu with the quit option, so users can easily stop the application.

+1
source

All Articles