Reputation: 1188
After spending half a day searching and trying, I'm finally giving up.
I have a java application of which I create a runnable jar (to include any other libs and just have a single jar file). With launch4j and the runnable jar I'm making an executable "MyApp.exe".
The executable ist working fine, but I want to pin it to my windows 7 taskbar. For now, I just have the taskbar entry "Close window".
After reading and implementing the following solutions with JNA
my Application displays it's "Application User Model ID" correctly in the gui (just for testing purpose).
BUT: my program is shown as "javaw.exe" in the Task Manager and I still can't pin it to the taskbar, even though I set the launch4j option "custom process name and XP style manifest".
Background information: I'm working with a windows 7 admin account and I don't want the app the require admin rights.
Anyways, if I start the app "as administrator" from the context menu and confirm the UAC message, I can now pin to the taskbar. BUT: even though I set the "Application User Model ID" properly, windows still wants to pin "javaw.exe", even though my program is now shown as "MyApp.exe" in the TaskManager.
I'm totaly confused. But I'm obviously not the only one, having these issues. => See the last comments to Gregory Pakosz answer in Using JNA to get/set application identifier
Final questions:
Upvotes: 29
Views: 6052
Reputation: 9971
The root cause: javaw
is registered as a Host process (in Windows' registry). The shortcut behaviour is probably caused by following (source: Application User Model IDs (AppUserModelIDs))
Application-Defined and System-Defined AppUserModelIDs
Some applications do not declare an explicit AppUserModelID. They are optional. In that case, the system uses a series of heuristics to assign an internal AppUserModelID.
[...]
if the process was launched through a shortcut that contains launch arguments (usually the target content to host as the "application"), the system can determine identity and the application can be pinned and relaunched.
About the Host Process behaviour:
Registering an Application as a Host Process
An application can set the IsHostApp registry entry to cause that executable's process to be considered a host process by the taskbar. This affects its grouping and default Jump List entries.
Upvotes: 1
Reputation: 13210
No problem with winrun4j either, which is newer and easier to use than Jsmooth
Upvotes: 1
Reputation: 689
Are you looking for this, which I used in my application to show the running Java application on windows taskbar..
SystemTray systemTray = new SystemTray(composite, parent.getShell(), parent.getDisplay(), "My Application");
systemTray.makeSystemTray();
Upvotes: 0