使用Launch4j将Java应用程序固定到Windows 7任务栏 [英] Pinning a Java application using Launch4j to the Windows 7 taskbar

查看:223
本文介绍了使用Launch4j将Java应用程序固定到Windows 7任务栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在尝试将Java应用程序固定到Windows 7任务栏。该应用程序使用 Launch4j 启动。程序图标显示正确,但右键单击任务栏上的图标仅显示带有关闭窗口条目的上下文菜单。没有用于将应用程序固定到任务栏的菜单项。将EXE文件拖到任务栏也无法正常工作。当在任务栏中单击这个新的启动器时,第二个图标会在任务栏中生成。

I'm currently trying to pin a Java application to the Windows 7 taskbar. The application is launched with Launch4j. The program icon is displayed correctly but right-clicking the icon on the taskbar only shows a context-menu with the entry "Close window". No menu entry for pinning the application to the taskbar. Dragging the EXE file into the taskbar is also not working properly. When clicking this new launcher in the taskbar then a second icon spawns in the taskbar.

我按照这两个问题的解决方案的说明来解决问题,但它没有不帮助:

I followed the instructions of the solutions to these two questions to solve the problem but it didn't help:

  • Pinning a Java application to the Windows 7 taskbar
  • Using JNA to get/set application identifier

来自第二个问题/解决方案的JNA内容编译并且不会抛出任何异常。我可以在设置后阅读应用程序ID。但是我仍然无法将应用程序固定到任务栏。

The JNA stuff from the second question/solution compiles and doesn't throw any exception. I can read the app id after setting it. But I still can't pin the application to the taskbar.

我在Github上创建了一个小测试应用程序来演示这个问题:

I have created a small test application on Github which demonstrates the problem:

https://github.com/kayahr/launch4jtest

该应用程序使用 Maven 作为构建系统。只需运行 mvn package ,您就会在目标目录中找到一个ZIP文件,其中包含设置此应用程序ID所需的EXE文件和jna.jar。将此ZIP解压缩到某个目录,双击EXE并尝试将应用程序固定到任务栏,您将看到问题。

The application uses Maven as build system. Simply run mvn package and you'll find a ZIP file in the target directory which contains the EXE file and the jna.jar which is needed to set this app id. Extract this ZIP to some directory, double-click the EXE and try to pin the application to the taskbar and you'll see the problem.

这个应用程序出了什么问题?

So what's wrong with this application?

推荐答案

NB根据kayahr的要求,在主帖中重写了一些评论:)

N.B. Rewritten some comments originally in the main post as per kayahr's request :)

您需要创建嵌入 AppUserModelID 信息的图标快捷方式。 InnoSetup可以在 [Icons] 部分下创建这样的图标快捷方式。通过JNA提供分配给 AppUserModelID 的应用程序名称。建议的阅读链接:

You need to create an icon shortcut that embeds AppUserModelID information. InnoSetup can create such icon shortcut under [Icons] section. Supply the application name assigned to AppUserModelID via JNA. Suggested links to read:

如何为izpack安装程序.jar文件制作.exe文件

Launch4j,NSIS和重复固定的Windows 7任务栏图标


  1. 将EXE文件(不是其图标快捷方式)拖放到Windows 7任务栏中以创建固定图标时,它可以正常工作;

  2. 运行EXE文件后,选择pin to taskbar选项菜单创建固定图标。如果您未设置 AppUserModelID ,则无法进行此操作;甚至它会导致奇怪的行为,比如在任务栏上使用javaw.exeicon而不是你的exe图标,因为Launch4J使用javaw.exe调用可执行jar(重复的固定图标)

  1. It works when dragging and dropping the EXE file (not its icon shortcut) into Windows 7 taskbar to create a pinned icon;
  2. It works when running the EXE file and later choosing "pin to taskbar" option menu to create a pinned icon. If you don't set AppUserModelID, this is not possible; even it will cause a weird behavior like having javaw.exe "icon" on the taskbar instead of your exe icon since Launch4J calls the executable jar using javaw.exe (duplicated pinned icons)

要在Linux下运行基于Windows的安装程序生成器,请参考此指南:

To run Windows-based installer builder under Linux, refer this as a guide:

http://katastrophos.net/andre/blog / 2009/03/16 / setup-up-inno-setup-compiler-on-debian /

是的,正如kayahr所说,这个Windows 7功能仅在其嵌入 AppUserModelID 的图标快捷方式保持不变(即未删除/删除)时才有效。

Yes, as mentioned by kayahr, this Windows 7 feature will only work when its icon shortcut with embedded AppUserModelID remains intact (i.e. it is not removed/deleted).

这篇关于使用Launch4j将Java应用程序固定到Windows 7任务栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆