Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pinning a Java application using Launch4j to the Windows 7 taskbar

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

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.

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

https://github.com/kayahr/launch4jtest

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?

like image 828
kayahr Avatar asked Feb 18 '12 15:02

kayahr


People also ask

What are the steps to pin an application into taskbar?

Select Start , scroll to the app you want to pin, then press and hold (or right-click) the app. Select More > Pin to taskbar. If the app is already open on the desktop, press and hold (or right click) the app's taskbar icon, and then select Pin to taskbar.


1 Answers

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

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:

How to make .exe file for izpack installer .jar file

Launch4j, NSIS, and duplicate pinned Windows 7 taskbar icons

  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)

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

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

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

like image 184
ecle Avatar answered Oct 08 '22 12:10

ecle