-2

I have a number of jar-files, some resources, h2 database, etc. in my project. To create Mac application I used Platypus. To run my application shell script was used.

However at this case when application starts then separate java process starts and there neither proper name of the app nor proper About description in Mac menu. Also Terminal starts that is not wanted.

How I should launch the app to avoid this drawbacks so that the name of the app and About description were the right ones?

What I see now (name and About):

enter image description here

enter image description here

My launching shell script is the following:

#!/bin/bash

export IRULE_HOME="$(cd "$(dirname "$0")" && pwd -P)"

export IRULE_LANG=en
export IRULE_REGION=EN
export IRULE_XMS=-Xms256m
export IRULE_XMX=-Xmx1024m
export LOG4J_CONFIGURATION=${IRULE_HOME}/conf/log4j2.xml
export JAVA_HOME="${IRULE_HOME}/jre/Contents/Home"

export DEFAULT_JVM_OPTS="$IRULE_XMS \
              $IRULE_XMX \
              -Dlog4j.configuration=file:"${LOG4J_CONFIGURATION}" \
              -Dirule.home=${IRULE_HOME} \
              -Dirule.client.logs.path=${IRULE_HOME}/logs \
              -Duser.language="${IRULE_LANG}" \
              -Duser.region="${IRULE_REGION}" \
              $JAVA_OPTS"


export PATH=${JAVA_HOME}/bin:${JAVA_HOME}:${PATH}
export CLASSPATH=${IRULE_HOME}/lib/*:${IRULE_HOME}/conf:${JAVA_HOME}/lib/jfxrt.jar;

exec ${JAVA_HOME}/bin/java -Xdock:name="iRule Reader" -Xdock:icon=${IRULE_HOME}/image/irule.png ${DEFAULT_JVM_OPTS} -classpath "${CLASSPATH}" com.spi2.Main $* 

How I created the app by Platypus. The process is simple: I set my shell-script and add all my resources. Also I can set up the icon. And I add Credits.html to allow About description as said in documentation:

enter image description here

Kirill Ch
  • 5,496
  • 4
  • 44
  • 65

1 Answers1

1

You could try running the Java apps/processes in headless mode.
Try adding this option to your DEFAULT_JVM_OPTS:

-Djava.awt.headless=true

But since your Java app has a GUI, that may not be a viable option.

You could also try implementing your own handlers for the system menu using the com.apple.eawt Apple Extensions classes (ex. AboutHandler, QuitHandler, etc.), as stated in their Java Development Guide for Mac docs:

The next step to customizing your application menu is to have your own handling code called when certain items in the application menu are chosen. Apple provides functionality for this in the com.apple.eawt.* Java classes. The Application and ApplicationAdaptor classes provide a way to handle the Preferences, About, and Quit items.

I could not find the actual API docs though.
Here are some other SO links which may help:

Gino Mempin
  • 25,369
  • 29
  • 96
  • 135
  • Yes. With this option there is an exception: Exception in thread "main" java.awt.HeadlessException ... However thanks for the information, I'll see these approaches. – Kirill Ch Aug 24 '17 at 14:45