tags:

views:

491

answers:

2

I have a Mac application bundle which is executing a shell script. The shell script calls java program 1 to do some stuff 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 any way to prevent the shell script application icon from showing in the Dock?

A: 

Yes, assuming the first Java program can run headless:

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

Addendum: If you are using JavaApplicationStub, diagnostic output from the launch process may be obtained as follows:

$ export JAVA_LAUNCHER_VERBOSE
$ ./YourBundle.app/Contents/MacOS/JavaApplicationStub
trashgod
I don't think it's the first java program's icon in the doc. I think that one goes away when the java program completes. It's like there is an icon for the shell script and one for the java program that is running. I want to get rid of the shell script icon.
G_A
Puzzling. If the JVM does anything that would throw a `HeadlessException`, you'll see a dock icon for it. Is the second process a child of the first? Are you using `JavaApplicationStub` or just your script?
trashgod
The JavaApplicationStub is not used. A shell script is what is getting executed. Each java program is being called separately by calling java...
G_A
A: 

Maybe you can run the Java program in the background and then exit the shell script? Something like this:

#!/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 might be to run the shell script without Terminal.app but directly with the Unix-level system(3) call or something similar, with no GUI interaction.

haa
This sounded like exactly what I needed, but the exit 0 line was not reached until after the second java program ended.
G_A