Home > Eclipse development, Software Development > Writing an Eclipse Plug-in (Part 6): Adding an Icon To New Project Types

Writing an Eclipse Plug-in (Part 6): Adding an Icon To New Project Types

So there you are: it’s the middle of the night and you suddenly wake up bathed in sweat with the question that has been haunting you for ages: how does a newly defined Eclipse project type get an associated image?

Adding an Icon to Newly Created Custom Projects

It has to do with natures. Remember how in Part 4 we added a custom nature to our custom project? Well, let’s put that custom nature to some use:

  1. Open customplugin plugin.xml –> Extensions. Click on org.eclipse.core.resources.natures. Note that its ID is customplugin.projectNature.
  2. From the Extensions tab click Add. Type proj in the Extensions window. The org.eclipse.ui.ide.projectNatureImages extension should be the only item left. Select it and click Finish.
  3. Right click on org.eclipse.ui.ide.projectNatureImages –> New –> image.
  4. Select customplugin.image1 (image), or whatever the name is of the new extension element, and enter the following in the fields to the right:
    • id: customplugin.natureImage
    • natureId: customplugin.projectNature
    • icon: icons/project-folder.png

The id is the name of this extension element. The natureId is the id of the nature created previously and the icon image is the project folder image we used with the New Project Wizard (feel free to use an image of your own choosing or making). I should probably have selected something a little less heavy handed as typically the icon is a smaller image that Eclipse overlays in the upper right hand corner of the folder icon. We’ll fix it eventually…maybe.

Go ahead. Run the runtime workbench and create a custom project. Open the Navigator view to take an unadulterated view of the project with its new shiny icon.


It’s okay. You can get some sleep now. The cat is alive.

  1. Pedro
    November 16, 2009 at 6:13 am

    Hello, I can not see the .project file in my custom navigator but I see this file in the normal navigator. Can you help me? Thanks.

  2. cvalcarcel
    November 16, 2009 at 10:43 pm

    Hi, Pedro!

    You can’t see the .project file in the custom navigator because I must have inadvertently turned off one of the display filters. If you click on the downward pointing arrow in the navigator menubar select Customize View.

    When the Available Customizations dialog opens, go to the Filters tab and uncheck .* resources. Click OK and the .project file will appear in the custom navigator.

    Thanks for pointing that out!

    • Pedro
      November 17, 2009 at 4:25 am

      Ok, thanks.

  1. December 3, 2013 at 12:53 am

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: