1

I've noticed that when running a .JAR file the unity launcher can be quite annoying.

If the JAR file is run in a terminal then the launcher icon is the one set in the application, as expected. However if it is run from nautilus with a double click or Open with... > OpenJDK then the title in the launcher is Open JDK and the icon is always the default icon. I think this is because java is opening the file rather than running it straight off (if that makes sense).

Is there any way to have the application's icon rather than the default if running it from nautilus, without making a .sh file or something similar to call it?

PS: I don't want it permanently in the launcher, therefore I don't want to create a .desktop file for it. I want it like any other application which when run appears in the launcher.

1

If you want an icon in the unity dock:

You need to create a *.desktop file for your program.

gksudo gedit /usr/share/applications/my-java-app.desktop

In the file

[Desktop Entry]
Name=the name you want shown
Comment=
Exec=java -jar <your jar file path>
Icon=<your preferred icon>
Terminal=false
Type=Application
StartupNotify=true

Now in your File manager, go to your Home folder and press ctrl+h to show hidden files.

Go to-> .gconf-> desktop-> unity-> favourites-> launchers

You'll see a bunch of folders starting with "app-". You need to create a folder for your program, use the same name as my-java-app.desktop you used in /usr/share/applications, go into 1 of the folders for something that is already on the dock & copy the xml file, paste that into your new folder & open it with the editor, change the name of the *.desktop to your my-java-app.desktop.

Now open gconf-editor & go to-> desktop-> unity-> favorites, double click the list on the right & add your my-java-app.desktop.

Log out and back in and you should see your launcher in the unity dock.

References:

http://ubuntuforums.org/showthread.php?t=1578379&p=9910899#post9910899

  • Please look at my edit. Also if you've made a .desktop for an application, the simplest way to get it onto the launcher is to search for it in the dash and drag it onto the launcher. – Adude11 Aug 31 '13 at 15:19
  • Hmm. In that case I'm sorry as I haven't quite figured that one out myself, I don't know why the icon wouldn't change to your JAR's icon. – Fahad Yousuf Sep 2 '13 at 20:46
  • I decided that it probably isn't possible. Do you think its possible that it's loading the application then passing the file to it? That's the only think I can think of, I tried making my own .desktop file just for jar files to see if that worked but no. – Adude11 Sep 3 '13 at 10:50
  • That is most probably true. Is the ps aux output any different for when you launch it from commandline (and the icon works as expected) and when you use Open with OpenJDK? – Fahad Yousuf Sep 3 '13 at 11:21
  • Actualiy the first part of the answer was enough to get it going. After adding the myapp.desktop i was able to open it with super+a. Once opened i simply rightclicked on the icon and choose keep in starter – DKSan Nov 1 '16 at 8:21

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.