Geertjan's Blog

  • January 16, 2013

Icons for NetBeans Platform Applications on Windows

Geertjan Wielenga
Product Manager

A recurring question in the NetBeans Platform world is: "How am I supposed to change the desktop shortcut icon and icons of the executables in the installation directory of a NetBeans Platform application installed on Windows via an installer created by the NetBeans Platform installer infrastructure?"

Let's use the Paint Application, one of the samples in the New Project wizard, as an example. Right-click the project node and choose "Package as | Installers". Now go outside NetBeans IDE and find the generated installer, double-click it, and complete the wizard.

On the desktop, you now see this desktop shortcut icon:

In the startup menu, you see this:

And in the installation directory, the icons for the executables look like this:

Sometimes, the above is fine and you don't care whether your own icons are used or not. Other times, you have a business requirement that all the above icons should be your custom icon. The first question to ask is: "Where does that orange NetBeans icon come from?" Well, take a look at your NetBeans installation directory and you'll find them:

Note: I am on 64-bit Windows, that's why you see a 64-bit executable above.

The above executables are NOT the executables for starting NetBeans IDE. Those executables are found in the "bin" folder above. Therefore, when we change the executables above, NetBeans IDE remains unaffected. So, don't worry, you'll still be able to start NetBeans IDE by the time you've worked through this blog entry.

Now that you know where the icons come from, you need to, in one way or another, change that icon to your own icon. In this FAQ entry you are shown how to do so. However, what that entry doesn't tell you is that you need to change those icons exactly where you see them above, i.e., not in your own "build" folder, since those will be overridden at some stage in the installer generator process, so that you'll only be partially successful, i.e., the executables for launching the application from the installation directory will be correctly changed, while the desktop shortcut icon will still be the orange NetBeans icon.

Here's what I do to override those orange NetBeans icons that you see above.

  1. Download the "ReplaceVistaIcon.exe", from here: http://www.rw-designer.com/rsrc/ReplaceVistaIcon.exe  and put the executable into the folder that you see in the screenshot above. That's right, the same folder where the executables are found that we're going to change.

  2. Get an ".ico" file, i.e., not some other kind of file, but one that is an icon file, i.e., the file extension is ".ico". Therefore, if you have ".png" file, for example, you'll need to somehow convert it to ".ico". For purposes of these steps, I am using Penguin.ico, which I found somewhere online. Put that file into the same folder as where the executables, and the utility from the previous step, are found.
  3. Now go to the command line. In the command line, cd into the folder shown above. Make sure that you have permissions on the folder and on the executables that you're going to change. Then type:

    ReplaceVistaIcon.exe app.exe Penguin.ico

    ...in the command line, which should change the icon of the first executable. Do the same for the other executables you find in the folder. If things go wrong at this stage, again, check the permissions on the folder and on the executables you're changing. When this step is complete, you'll see the following, where you can see I have selected the Penguin icon and the ReplaceVistaIcon utility, while the executables that have been changed are clearly different, i.e., no more orange NetBeans icons can be seen below:

  4. Now you're ready to regenerate your installer. Start by running "Clean" on your application, to make sure that your 'build' folder and 'dist' folder are removed. Then create the installer again and then run the installer, as you did before.

    And here's the result, after running the installer. Firstly, the desktop shortcut icon:

    Secondly, the start menu:

    Finally, the launchers (i.e., the executables) of the application:

Tip: If the desktop shotcut icon is still not correct after the above procedure, restart your computer. I've noticed this happen sometimes, probably because I didn't uninstall a previous version of the application correctly and there was still some cached data in the .paintit-installer folder.

The above is not the prettiest solution, but it works. If you're wondering: "OK, but I have multiple applications, must I do the above for each of those applications, i.e., will I have to do this over and over again whenever I create an installer for one of my applications?" And the answer is: "Yes." Again, not pretty. But it works. And that's what this blog is all about.

Join the discussion

Comments ( 6 )
  • guest Thursday, January 17, 2013

    When it is so laborious, it is worth a RFE!

    I think could be even easier: The nbi-installer could create the *.lnk using a customer defined icon. So no resourcehack in the exe file is necessary. This way the custom icon is seen on the desktop and in the startmenu. The original *.exe stays untouched.

    Geertjan, what do you think about it?

  • Geertjan Thursday, January 17, 2013

    Sounds like a great solution, feel free to file that RFE.

  • markiewb Thursday, January 17, 2013
  • Steven Yi Thursday, January 17, 2013

    I don't remember where I got this, but I use the following ant snippet:

    <!-- Windows-only target that replaces the icon for the launcher exe with our own icon. -->

    <target name="replaceWindowsLauncherIcon" if="isWindows" description="Replace the icon for the Windows launcher exe">

    <echo message="Replacing icon of Windows launcher executable."/>

    <exec executable="C:\bin\ReplaceVistaIcon.exe" resolveexecutable="true">

    <arg line="build/launcher/bin/${app.name}.exe ${app.name}.ico"/>


    <exec executable="C:\bin\ReplaceVistaIcon.exe" resolveexecutable="true">

    <arg line="build/launcher/bin/${app.name}64.exe ${app.name}.ico"/>



    and I override build-launchers with:

    <target name="build-launchers" depends="suite.build-launchers">

    <!-- Replace the icon for the Windows launcher exe. -->

    <antcall target="replaceWindowsLauncherIcon"/>

    <copy file="${harness.dir}/etc/app.conf"




    <replacestring from="$${branding.token}" to="${branding.token}"/>

    <replacestring from="-J-Xms24m -J-Xmx64m" to="${confReplacementString}"/>



    <antcall target="addLinuxJavaLibraryPath"/>


    I also have this near the top of my build.xml:

    <condition property="isWindows">

    <os family="windows" />


    With this I have the launcher replaced every time I build. (Note, I can't take credit for this, but I don't remember where I found this online to credit.)

  • David Beer Friday, January 18, 2013

    Hi Steven/Gertjan

    I remember finding something myself and various other settings you can define via your pom and the nbi-installer script, this was found searching the internet, trial error and looking at how the NetBeans team produce there installer.

  • guest Wednesday, February 3, 2016


    I have a maeven project so my app.exe and app64.exe are located in ProjectName, target, projectName, bin.

    I did what you say in the netbeans folder and I succeed changing the icons in this folder. Nevertheless even after restarting my computer, cleaning and building again my project, the icon is still the default icon.

    I don't know how to deal with that.

    Note : when I right click on my application, I don't have "package as" as I am suppose to have...

    Can someone help me please?

    Thanks a lot

Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.