Adding Desktop Icons to sdkman managed packages

When you install package like jmc or VisualVM from sdkman, the installation is for your current user only, so it doesn’t create desktop shortcuts allowing you to start program from Gnome or KDE app launchers. Unfortunately this by design forces users to start application from command line, even when it’s a desktop application.

To fix it, and be able to run jmc from Alt+F2 launcher you need to create your own desktop file like this:

#!/usr/bin/env xdg-open
[Desktop Entry]
Name=JMC Java Mission Control
Exec=/home/agilob/.sdkman/candidates/jmc/current/bin/jmc %U
Terminal=false
Type=Application
Icon=/home/agilob/.sdkman/candidates/jmc/current/JDK Mission Control/icon.xpm
StartupWMClass=JMC
X-AppImage-Version=current
Comment=Java Mission Conrol
Categories=Development;

JMC and VisualVM come with their own icons in candidate directory, so let’s trust it will always be there.

#!/usr/bin/env xdg-open
[Desktop Entry]
Name=VisualVM
Exec=/home/agilob/.sdkman/candidates/visualvm/current/bin/visualvm %U
Terminal=false
Type=Application
Icon=/home/agilob/.sdkman/candidates/visualvm/current/etc/visualvm.icns
StartupWMClass=VisualVM
X-AppImage-Version=current
Comment=Java Visual VM
Categories=Development;

Now, these two files need to be saved in /usr/share/applications and you’re able to start JMC from Alt+F2: img