开发者

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

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 a开发者_StackOverflow中文版pplication. 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?


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


If you don't want the shell script icon in the dock, you need to start, at least the second java process for the main application, in exec mode:

exec java -jar XXX

exec means, it will "replace" your currently running shell with the new process. This seams exactly what you want.

My universalJavaApplicationStub for Java 6/7 is doing it the same way and it works just fine :)


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜