How to create an icon launcher for your application in Ubuntu 18.04+
If you create an application in Java or C++you might want to have a custom icon launcher for your application. With such a launcher you can simply start you application through the Ubuntu desktop environment (GNOME) instead of running it from the command line.
This is not only useful for the applications you build on your own. It also happens often that cross-platform applications, like e.g. Postman, does not provide such a launcher.
In this case you can simply create your own launcher by the following steps.
Step 1:
Find an icon for your application which has a size of 404px by 404px. This ensures a nice look in the dock.
Step 2:
Place your application and the icon in a separate folder and place it to your needs e.g. “/opt/[MyJavaApplication]”
Step 3:
Find the StartupWMClass of your application by running the command “xprop WM_CLASS” in your terminal and clicking on the main window of your running application. GNOME uses this to associate windows with the owning application.
For example, if you’re doing this on a running Chrome Browser, the result should look likes this:
Step 4:
Go to go to /home/[your username]/.local/share/applications, create a “[MyJavaApplication].desktop“-file and paste the following content to it:
Step 5:
After saving the file you can instantly search for your app in GNOME app search and launch it from there. Further you’re able to set your app as favorite direct to your dock.
Final thoughts:
Creating an icon launcher is not that complicated as it seems and it make your system more convenient to you.