Mac shell script running java program puts two icons in the dock

I have a Mac application package that runs a shell script. The shell script calls java program 1 to do something, and then launches the main Java application. This process leaves one icon in the Dock for the shell script, which shows the name from the application folder and one icon in the Dock for the java program.

Is there a way to prevent the shell script application icon from appearing in the dock?

+3
source share
3 answers

Yes, if the first Java program can run headless :

java -Djava.awt.headless=true ...

: JavaApplicationStub, :

$ export JAVA_LAUNCHER_VERBOSE
$ ./YourBundle.app/Contents/MacOS/JavaApplicationStub
+6

script , , , Java- exec:

exec java -jar XXX

exec , "" . , .

My universalJavaApplicationStub Java 6/7 , :)

+1

, Java , script? - :

#!/bin/sh
first_java_program            # Synchronous, wait for it
nohup second_java_program &   # Run in the background, detach from terminal
exit 0                        # Indicate clean exit

Another option would be to run a shell script without Terminal.app, but directly with a system call (1) at the Unix level or something similar, without interacting with the graphical interface.

0
source

Source: https://habr.com/ru/post/1730290/


All Articles