blob: 3002b6718a73c0510f472d1f2293f853a62103fb [file] [log] [blame]
//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
//
= DevFaqExecutableIcon
:jbake-type: wiki
:jbake-tags: wiki, devfaq, needsreview
:jbake-status: published
:keywords: Apache NetBeans wiki DevFaqExecutableIcon
:description: Apache NetBeans wiki DevFaqExecutableIcon
:toc: left
:toc-title:
:syntax: true
=== 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: link:http://www.netbeans.org/nonav/issues/show_bug.cgi?id=64612[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 link:http://www.rw-designer.com/compile-vista-icon[ RealWorld Graphics] works well, and can be invoked as simply as:
[source,java]
----
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:
[source,xml]
----
<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:
* link:http://www.angusj.com/resourcehacker[http://www.angusj.com/resourcehacker]
* link:http://www.wilsonc.demon.co.uk/d10resourceeditor.htm[http://www.wilsonc.demon.co.uk/d10resourceeditor.htm]
If you need an editor for creating/converting both Windows `.ico` files and Mac `.icns` files, try the excellent, program link:http://icofx.ro/[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:
[source,xml]
----
<!-- 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 link:http://www.kiyut.com[http://www.kiyut.com]) build script posted on: link:http://forums.netbeans.org/ptopic10504.html[http://forums.netbeans.org/ptopic10504.html]
Since Netbeans 6.9 (link:http://netbeans.org/bugzilla/show_bug.cgi?id=182230+&x=23&y=2[Issue #182230]) is possible to specify the Mac dock icon just by setting the property `app.icon.icns in` your `build.xml`
[source,xml]
----
<import file="nbproject/build-impl.xml"/>
<property name="app.icon.icns" value="${basedir}/myappicon.icns"/>
----
==== Related links
* link:https://blogs.oracle.com/geertjan/entry/icons_for_netbeans_platform_applications[https://blogs.oracle.com/geertjan/entry/icons_for_netbeans_platform_applications]
=== Apache Migration Information
The content in this page was kindly donated by Oracle Corp. to the
Apache Software Foundation.
This page was exported from link:http://wiki.netbeans.org/DevFaqExecutableIcon[http://wiki.netbeans.org/DevFaqExecutableIcon] ,
that was last modified by NetBeans user Jmborer
on 2015-04-28T11:14:08Z.
*NOTE:* This document was automatically converted to the AsciiDoc format on 2018-02-07, and needs to be reviewed.