DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
View Events Video Library
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Integrating PostgreSQL Databases with ANF: Join this workshop to learn how to create a PostgreSQL server using Instaclustr’s managed service

Mobile Database Essentials: Assess data needs, storage requirements, and more when leveraging databases for cloud and edge applications.

Monitoring and Observability for LLMs: Datadog and Google Cloud discuss how to achieve optimal AI model performance.

Automated Testing: The latest on architecture, TDD, and the benefits of AI and low-code tools.

Related

  • My Experiences with Maven in IntelliJ IDEA and NetBeans IDE
  • How To Deploy Helidon Application to Kubernetes With Kubernetes Maven Plugin
  • Deploy MuleSoft App to CloudHub2 Using GitHub Actions CI/CD Pipeline
  • Ensuring Reliable Microservice Deployment With Spring Boot Build Info Maven Plugin

Trending

  • Analyzing Stock Tick Data in SingleStoreDB Using LangChain and OpenAI's Whisper
  • Five Free AI Tools for Programmers to 10X Their Productivity
  • Decoding Business Source Licensing: A New Software Licensing Model
  • OneStream Fast Data Extracts APIs
  1. DZone
  2. Coding
  3. Java
  4. How to Change a NetBeans Platform Executable Icon with Maven

How to Change a NetBeans Platform Executable Icon with Maven

Timon Veenstra user avatar by
Timon Veenstra
·
Jan. 23, 13 · Interview
Like (0)
Save
Tweet
Share
10.49K Views

Join the DZone community and get the full member experience.

Join For Free

When building an application based on the NetBeans rich client platform, you probably want to ship it eventually with your own branding. One part of this branding is the icon of the executable.

Since icons are binary embedded into windows executables, we need an external tool to hack our own branded icon into the generated executable. This post describes how to do this using maven as a build tool.

The complete configuration

  • run mvn nbm:build-installers once in your myProject/application folder
  • copy myProject/application/target/installer/nbi/stub/template.xml to myProject/application/installer/template.xml
  • copy your own 48x48 png or gif icon to myProject/application/installer/
  • create a .ico file from your png icon with the gimp or another graphical editor
myProject/pom.xml:

    <properties>
        <brandingToken>agrosense</brandingToken>
        <application.ico>${basedir}/installer/agrosense.ico</application.ico>
...
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>nbm-maven-plugin</artifactId>
                    <version>3.8.1</version>
                    <extensions>true</extensions>
                    <configuration>
                        <brandingToken>${brandingToken}</brandingToken>
                        <cluster>${brandingToken}</cluster>
                        <etcConfFile>${basedir}/installer/application.conf</etcConfFile>
                        <templateFile>${basedir}/installer/template.xml</templateFile>
                         <userSettings>
                            <releaseVersion>${releaseVersion}</releaseVersion>
                            <!-- this will replace the icon in the upper left corner of the installation wizard -->
                            <nbi.instleftcorner.file>${basedir}/installer/agrosense_icon48.png</nbi.instleftcorner.file>
                            <!-- this will replace the icon file in the installed application folder -->
                            <nbi.icon.file>${basedir}/installer/agrosense_icon48.png</nbi.icon.file>
                        </userSettings>                    
                    </configuration>
                </plugin>


  • install Resource Hacker  (when using linux, first install java in a wine bottle and then install Resource Hacker in the same bottle)
  • add local configuration profile to your ~/.m2/settings.xml  (change when needed):
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
                      http://maven.apache.org/xsd/settings-1.0.0.xsd">
    <profiles>
        <profile>
            <id>replace-icon-config</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <properties>
                <wine.bottle>${user.home}/.bottles/iconFixer</wine.bottle>
                <resourcehacker.installdir>C:\Program Files (x86)\Resource Hacker\</resourcehacker.installdir>
            </properties>
        </profile>
    </profiles>
</settings>

  • add the following profiles to your myProject/application/pom.xml. (they are not application specific, so they should work without adjustment)
         <profile>
            <id>replace-icon-unix</id>
            <activation>
                <os>
                    <family>Unix</family>
                </os>
                <file>
                    <exists>${wine.bottle}\drive_c\${resourcehacker.installdir}\ResHacker.exe</exists>
                </file>                     
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-antrun-plugin</artifactId> 
                        <version>1.7</version>
                        <executions>
                            <execution>
                                <phase>package</phase>
                                <goals>
                                    <goal>run</goal>
                                </goals>                        
                                <configuration>
                                    <target> 

                                        <echo message ="Replacing icon of Windows launcher executable" /> 
                                        <!-- replace executable with ResHacker.exe path on windows -->
                                        <exec executable="wine" resolveexecutable="true" logerror="true">
                                            <!-- replace value with location of installation bottle, or remove on windows -->
                                            <env key="WINEPREFIX" value="${wine.bottle}" />
                                            <!-- remove this argument when running on windows -->
                                            <arg value="${resourcehacker.installdir}\ResHacker.exe"/>
                                            <arg value="-addoverwrite"/>
                                            <arg value="${project.build.directory}/${brandingToken}/bin/${brandingToken}.exe,"/>
                                            <arg value="${project.build.directory}/${brandingToken}/bin/${brandingToken}.exe,"/>
                                            <arg value="${application.ico},"/>
                                            <arg value="ICONGROUP,"/>
                                            <arg value="MAINICON,"/>
                                            <arg value="0"/>
                                        </exec>      
                     
                                        <zip destfile="${project.build.directory}/${project.artifactId}-${project.version}.zip" update="true"> 
                                            <zipfileset dir="${project.build.directory}/${brandingToken}/bin" includes="*.exe" prefix="${brandingToken}/bin" /> 
                                        </zip>            
                                    </target>       
                                </configuration>                      
                            </execution>
                        </executions>
                    </plugin>  
                </plugins>
            </build>
        </profile>                    
        <profile>
            <id>replace-icon-windows</id>
            <activation>
                <os>
                    <family>Windows</family>
                </os>
                <file>
                    <exists>${resourcehacker.installdir}\ResHacker.exe</exists>
                </file>                            
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-antrun-plugin</artifactId> 
                        <version>1.7</version>
                        <executions>
                            <execution>
                                <phase>package</phase>
                                <goals>
                                    <goal>run</goal>
                                </goals>                        
                                <configuration>
                                    <target> 

                                        <echo message ="Replacing icon of Windows launcher executable" /> 
                                        <!-- replace executable with ResHacker.exe path on windows -->
                                        <exec executable="${resourcehacker.installdir}\ResHacker.exe" resolveexecutable="true" logerror="true">
                                            <arg value="-addoverwrite"/>
                                            <arg value="${project.build.directory}/${brandingToken}/bin/${brandingToken}.exe,"/>
                                            <arg value="${project.build.directory}/${brandingToken}/bin/${brandingToken}.exe,"/>
                                            <arg value="${application.ico},"/>
                                            <arg value="ICONGROUP,"/>
                                            <arg value="MAINICON,"/>
                                            <arg value="0"/>
                                        </exec>      
                     
                                        <zip destfile="${project.build.directory}/${project.artifactId}-${project.version}.zip" update="true"> 
                                            <zipfileset dir="${project.build.directory}/${brandingToken}/bin" includes="*.exe" prefix="${brandingToken}/bin" /> 
                                        </zip>            
                                    </target>       
                                </configuration>                      
                            </execution>
                        </executions>
                    </plugin>                       
                </plugins>                  
            </build>
        </profile>
Icon Executable Apache Maven NetBeans

Opinions expressed by DZone contributors are their own.

Related

  • My Experiences with Maven in IntelliJ IDEA and NetBeans IDE
  • How To Deploy Helidon Application to Kubernetes With Kubernetes Maven Plugin
  • Deploy MuleSoft App to CloudHub2 Using GitHub Actions CI/CD Pipeline
  • Ensuring Reliable Microservice Deployment With Spring Boot Build Info Maven Plugin

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends: