Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 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, stephenmyall, 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.

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]

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 – ose Jan 28 '12 at 23:18

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