Ubuntu – Ubuntu 17.10 not showing Spring Tool Suite icon in the Dock

17.10gnome-shelliconsubuntu-dock

This question is related to this one: Ubuntu 16.04 Eclipse launcher icon problems, however I have installed Eclipse and STS.

I have created a .desktop file for each of them, basically just copy-pasting and changing the paths for them. My Eclipse IDE icon is showing but STS isn't, here's a SS showing what I mean:

enter image description here

Here are both of my .desktop files:

Eclipse.desktop:

[Desktop Entry]
Type=Application
Name=eclipse
Comment=Eclipse IDE
Icon=/app/tools/eclipse/eclipse/icon.xpm
Exec=/app/tools/eclipse/eclipse/eclipse
Terminal=false
Categories=Development;IDE;Java;
StartupWMClass=eclipse

STS.desktop:

[Desktop Entry]
Type=Application
Name=STS
Comment=Spring Tool Suite
Icon=/app/tools/spring-tool-suite-3.9.1.RELEASE-e4.7.1a-linux-gtk-x86_64/sts-bundle/sts-3.9.1.RELEASE/icon.xpm
Exec=/app/tools/spring-tool-suite-3.9.1.RELEASE-e4.7.1a-linux-gtk-x86_64/sts-bundle/sts-3.9.1.RELEASE/STS
Terminal=false
Categories=Development;IDE;Java;
StartupWMClass=STS

As you can see, both of them are practically identical except for the paths and names.

I made both of them following the accepted answer in this question: How to pin Eclipse to the Unity launcher?

Something curious is that if I use the "search" option, I can see the app with the icon but not on the Launcher, how to solve this? So I can pin it to the Dock?

enter image description here

While I'm familiar with Ubuntu, I've used it on 16.04 and earlier versions and it "automagically" showed the icon for me when downloaded and installed, so this was something strange for me this time.

Best Answer

It seems STS is not a correct StartupWMClass value in the STS.desktop file.

To get a correct value first switch to an Xorg session and launch Spring Tool Suite. Then open Terminal and run xprop WM_CLASS, place the cursor over the STS window and click. You should get correct values for Spring Tool Suite in the Terminal window as

WM_CLASS(STRING) = "value1", "value2"

You should get something like the following in particular

WM_CLASS(STRING) = "Spring Tool Suite", "Spring Tool Suite"

Then change the StartupWMClass=STS line to StartupWMClass=Spring Tool Suite in the STS.desktop file and save it.