Score:2

Providing an Icon for the taskbar for a java application

dz flag

I have a java application packaged as an executable file with JavaPackager. The content of the tar.gz file is:

  • a PNG file (provided by me - 128px/128px )
  • a folder with all the .jar libs
  • an executable file (bash shell)

When that application is executing, its icon is displayed in the taskbar, but in an ugly way, like an enlarged small icon:

Application's icon in the taskbar

Most questions/answers about taskbar icons deal with editing manually a myapplication.desktop file.

I'd like to find an automated solution. Where the icon is directly correct, even at other DPI's, without requiring any user action.

What would it be ? Adding other icons, at other sizes ? Adding in the package another file ?

EDIT:

I've finally added a myapplication.desktop file. And if the icon is properly rendered in the application menu

Icon in the application menu

it keeps being wrongly rendered in the taskbar

Score:1
dz flag

The key is having the right xxx.desktop file.

The application is a java application and is known by the OS under its main class name. So if the main class of the application is foo.bar.MyApplication.class the OS knows the application as foo-bar-MyApplication.

So the solution is to create the following file:

~/.local/share/applications/foo-bar-MyApplication.desktop

With the following content:

[Desktop Entry]
Encoding=UTF-8
Version=1.0
Type=Application
Terminal=false
Name=My Wonderful Application
Icon=/path/to/a/wondefull/icon.png

This is the simplest solution. JavaPackager is, at this stage, not involved. This is achieved by the Java code itself.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.