运行 java 程序的 Mac shell 脚本将两个图标放入 Dock 中

发布于 2024-08-19 02:02:43 字数 196 浏览 2 评论 0原文

我有一个正在执行 shell 脚本的 Mac 应用程序包。 shell 脚本调用 java 程序 1 来做一些事情,然后启动主 java 应用程序。此过程在 Dock 中为 shell 脚本留下一个图标,该脚本显示应用程序文件夹中的名称,并在 Dock 中为 java 程序留下一个图标。

有什么方法可以阻止 shell 脚本应用程序图标显示在 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 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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

幻想少年梦 2024-08-26 02:02:43

是的,假设第一个 Java 程序可以运行 headless

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

附录:如果您使用 JavaApplicationStub,则可以按如下方式获取启动过程的诊断输出:

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

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
从来不烧饼 2024-08-26 02:02:43

如果您不希望 Dock 中出现 shell 脚本图标,则需要以 exec 模式启动主应用程序的至少第二个 java 进程:

exec java -jar XXX

exec 意味着,它将用新进程“替换”当前正在运行的 shell。这正是您想要的接缝。

我的 Java 6/7 的 universalJavaApplicationStub 也是以同样的方式做的,而且效果很好:)

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 :)

放赐 2024-08-26 02:02:43

也许你可以在后台运行Java程序,然后退出shell脚本?像这样的事情:

#!/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

另一种选择可能是在没有 Terminal.app 的情况下运行 shell 脚本,但直接使用 Unix 级 system(3) 调用或类似的东西,没有 GUI 交互。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文