Wednesday Jan 16, 2013

Icons for NetBeans Platform Applications on Windows

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.

About

Geertjan Wielenga (@geertjanw) is a Principal Product Manager in the Oracle Developer Tools group living & working in Amsterdam. He is a Java technology enthusiast, evangelist, trainer, speaker, and writer. He blogs here daily.

The focus of this blog is mostly on NetBeans (a development tool primarily for Java programmers), with an occasional reference to NetBeans, and sometimes diverging to topics relating to NetBeans. And then there are days when NetBeans is mentioned, just for a change.

Search

Archives
« January 2013 »
SunMonTueWedThuFriSat
  
25
26
27
30
  
       
Today