Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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.

share|improve this question

migrated from stackoverflow.com Jan 29 '12 at 18:45

This question came from our site for professional and enthusiast programmers.

marked as duplicate by Andrea Corbellini, bodhi.zazen, Stephen Myall, Eliah Kagan, Eric Carvalho Feb 5 '13 at 1:40

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1 Answer 1

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.

share|improve this answer
    
Thank you for your help. My file is current ".sh" type. Are you suggesting I change the extension to .desktop? –  Peter Jan 28 '12 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 '12 at 23:18
    
updated with an example for making a .desktop to launch a .sh file. –  Mateo Jul 6 '12 at 1:43

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