Apache NetBeans
Apache NetBeans
Latest release

Apache NetBeans 24

Download

How can I change the executable’s icon?

In short, the current NetBeans IDE (6.7) only provides limited support for changing application icons. Alternate solutions are described below, but NetBeans itself does not include any way to change the icon of the Windows launcher executable called <your branding name>.exe, nor does it provide a way to specify an .icns file for Mac OS X. There is already an enhancement request for Windows icon support: issue #64612.

'Application Icon' Images

NetBeans only provides GUI support for choosing a 48x48 GIF or PNG image, within the Project Properties dialog on the Build screen. Using this screen produces two files within your project’s branding/core/core.jar/org/netbeans/core/startup folder: frame.gif and frame48.gif. However, these files are crudely resized from the selected image. For this reason, and because a 32x32 icon is not generated, it is best to create the image files for the three icon sizes yourself using another editor, and then simply place them into the startup folder mentioned above.

Similar to toolbar icons, these files always use the .gif extension, regardless of their actual format. The frame.gif file is used for the smallest icon size of 16x16, which shows up in three places: the taskbar (Windows/Linux), in the upper-left corner of the application’s title bar (Windows/Linux), and in the upper-left corner of most dialog windows (Windows/Linux). Another file called frame32.gif (which is not generated by the NetBeans Project Properties dialog) provides a 32x32 icon that shows up in the Alt-Tab menu on Windows. Lastly, the frame48.gif file provides a 48x48 icon that shows up in the Alt-Tab menu on Linux.

Windows Icons

This refers to the icon of the Windows launcher executable as seen in Windows Explorer or when you make a shortcut to it on your Windows desktop. The Windows executable is found within <your project>\build\launcher\bin\ and is an identical copy of <NetBeans install location>\harness\launchers\app.exe that has simply been renamed to the branding name that you have specified within the Project Properties dialog on the Build screen (which is actually saved as the app.name property in project.properties). Although the NetBeans IDE can’t change this icon, you can use a third-party utility program to replace the exe’s icon with an .ico of your own.

If you want a simple commandline program to call as part of your Windows build process, the free ReplaceVistaIcon.exe from RealWorld Graphics works well, and can be invoked as simply as:

ReplaceVistaIcon.exe build\launcher\bin\<your branding name>.exe YourIconFile.ico

To do this automatically when building, simply place a copy of ReplaceVistaIcon.exe and <your branding name>.ico into your project’s root directory (where build.xml is), and add the following to your suite’s Build Script (build.xml) after the import line:

	<condition property="isWindows">
		<os family="windows" />
	</condition>

	<target name="build-launchers" depends="suite.build-launchers">
		<!-- Replace the icon for the Windows launcher exe. -->
		<antcall target="replaceWindowsLauncherIcon"/>
	</target>

	<!-- 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="ReplaceVistaIcon.exe" resolveexecutable="true">
			<arg line="build/launcher/bin/${app.name}.exe ${app.name}.ico"/>
		</exec>
	</target>

If you would prefer to simply do it manually and need a GUI resource editor, try the free programs:

If you need an editor for creating/converting both Windows .ico files and Mac .icns files, try the excellent, program IcoFX (no longer free).

Mac Icons

The "Build Mac OS X Application" command in NetBeans uses a default icon from <NetBeans install location>/harness/etc/applicationIcon.icns. You can change this icon after a Mac build by simply replacing the file <your project>/dist/<your branding name>.app/Contents/Resources/<your branding name>.icns with your own .icns file of the same name.

In order to replace it automatically when building, name your .icns file as <your branding name>.icns and place a copy into your project’s root directory (where build.xml is), and add the following to your suite’s Build Script (build.xml) after the import line:

	<!-- Override to change Mac application icon. -->
	<target name="build-mac" depends="suite.build-mac" description="Build Mac OS X Application">
		<property name="nbdist-contents.dir" value="${dist.dir}/${app.name}.app/Contents"/>
		<property name="nbdist-resources.dir" value="${nbdist-contents.dir}/Resources"/>

		<!-- Replace the icns file. -->
		<delete file="${nbdist-resources.dir}/${app.name}.icns"/>
		<copy tofile="${nbdist-resources.dir}/${app.name}.icns" file="${app.name}.icns" />
	</target>

This is a simplified version of Tonny Kohar’s (of http://www.kiyut.com) build script posted on: http://forums.netbeans.org/ptopic10504.html

Since Netbeans 6.9 (Issue #182230) is possible to specify the Mac dock icon just by setting the property app.icon.icns in your build.xml

   <import file="nbproject/build-impl.xml"/>
   <property name="app.icon.icns" value="${basedir}/myappicon.icns"/>