4

Possible Duplicate:
Apply icons to bash scripts

Environment: Ubuntu 11.10

I have a Java application as a jar file. I have created a batch file that contains the following line:

java -jar ~/MyApp.jar

When I execute this batch file, the Java application works as expected.

To create a desktop link, I copied this batch file into my "Desktop" folder. This results in an icon appearing on the desktop. However, the icon shows "Java" on it. I would like to associate a different icon to this desktop link. Would appreciate it if someone can point me in the right direction.

1
  • New users and guests, this is for you. Please note the duplicate question above. Please use it instead.
    – fosslinux
    Aug 4, 2016 at 2:44

1 Answer 1

8

Try modifying your .desktop file. Look for the [Desktop Entry] for your java file and change the Icon value.

Making a "launcher" that will run your script will let you do this. Make a file called MyApp.desktop then edit it with a text editor like gedit.

Next paste this code into the file, changing the values for your program-

[Desktop Entry]
Type=Application
Name=MyApp
Terminal=true
Exec=/usr/bin/MyApp.sh
Icon=/usr/share/icons/icon.icon

For Exec= put the path and name of your script file, for Icon put the location and name of the icon you want. For Terminal= put true or false if you want it to show the terminal or not.

This will give you a file that you can put anywhere, in the unity launcher, or on the desktop that you can run the script and it will have the icon you want.

On The newer versions of Ubuntu you will need to right click the file and select "allow launching".

2
  • Thank you for your help. My file is current ".sh" type. Are you suggesting I change the extension to .desktop?
    – Peter
    Jan 28, 2012 at 20:15
  • Here is a link that will explain how to set up a .desktop file standards.freedesktop.org/desktop-entry-spec/latest
    – ose
    Jan 28, 2012 at 23:18

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