How to associate an icon with a shell script? [duplicate]

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".