How to set custom icon for javafx native package icon on Windows
Asked Answered
F

3

9

I am trying to chance the icon of the exe file while creating native bundling of javafx packaging. I tried adding icon into pom.xml but till it wont work out for me as it gives default icon
Using Intellij IDEA IDE which contain an Pom.xml creating an package by command = mvn jfx:build-native Here is my pom.xml:

<build>
    <plugins>
        <plugin>
            <groupId>com.zenjava</groupId>
            <artifactId>javafx-maven-plugin</artifactId>
            <version>1.5</version>
            <configuration>

                <mainClass>com.demoApp.testapp.testApplication</mainClass>

                <!-- only required if signing the jar file -->
                <keyStoreAlias>example-user</keyStoreAlias>
                <keyStorePassword>example-password</keyStorePassword>
                <permissions>
                    <permission>all-permissions</permission>
                </permissions>
                <icon>${basedir}/src/main/resources/images/logoIcon.ico</icon>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>1.7</source>
                <target>1.7</target>
            </configuration>
        </plugin>

    </plugins>
</build>

I have added an icon path into pom.xml ${basedir}/src/main/resources/images/logoIcon.ico that will run while native package execute but it wont work out for me

Is any other way to do it ? Please suggest.


i tried fx tags in pom.xml using ant,here is my changes in pom.xml

<properties>

<javafx.tools.ant.jar>${env.JAVA_HOME}\lib\ant-javafx.jar</javafx.tools.ant.jar> </properties>


<plugin>
                <artifactId>maven-antrun-plugin</artifactId>
                <version>1.6</version>
                <executions>
                    <execution>
                        <id>create-launcher-jar</id>
                        <phase>package</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <configuration>
                            <target xmlns:fx="javafx:com.sun.javafx.tools.ant">
                                <taskdef
                                        uri="javafx:com.sun.javafx.tools.ant"
                                        resource="com/sun/javafx/tools/ant/antlib.xml"
                                        classpath="${javafx.tools.ant.jar}"/>
                                <fx:application id="fxApp"
                                                name="${project.name}"
                                                mainClass="com.precisionhawk.flightplanner.FlightPlannerApp"/>
                                <fx:jar destfile="${project.build.directory}/${project.build.finalName}-launcher">
                                    <fx:application refid="fxApp"/>
                                    <fx:fileset dir="${project.build.directory}/classes"/>
                                </fx:jar>
                                <attachartifact file="${project.build.directory}/${project.build.finalName}-launcher.jar"
                                                classifier="launcher"/>
                                <fx:deploy>
                                    <fx:info>
                                        <fx:icon href="${basedir}/src/main/deploy/logoIcon.ico"></fx:icon>
                                    </fx:info>

                                </fx:deploy>
                            </target>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

but it wont work out..

Ferretti answered 8/4, 2013 at 13:17 Comment(1)
the windows folder's name is missing in your code here: <fx:icon href="${basedir}/src/main/deploy/logoIcon.ico"></fx:icon>Omni
T
13

I just struggled with the same issue using Zonsky's great javafx-maven-plugin. As of version 1.5, which you also were using, the src/main/deploy directory will be added to the classpath. The icon you want to use could be added there and it will be available on the classpath for the native builder!

I added src/main/deploy/package/windows/myapp.ico there and it finally worked :)

For you:

  1. Create src/main/deploy/package/windows/ folder
  2. Add icon with name ${project.build.finalName}.ico
  3. Run mvn jfx:build-native

I haven't played with it extensively - just got it to work and wanted to share. So if you want to use icon with different name, I don't know how. Not yet at least. The <icon>...</icon> section in the config section seems to be for webstart, so I haven't been using it. Hope you get it to work!

Tova answered 10/5, 2013 at 7:23 Comment(0)
I
1

You need to look at the logging while building a native app. That will tell you where the installer looks for the icon files and with wich name. For the default Windows native app it looks in ./package/windows/'appname'.ico Can't remember where 'appname' comes from, but just look at the logging while building, it will tell you. (I use the Ant targets called from my pom btw)

Informative answered 10/4, 2013 at 11:45 Comment(8)
log while building a native app: [INFO] Building Native Installers [DEBUG] Using icon file at 'C:\Projects\DemoApp\src\main\deploy\logoIcon.ico' its getting an path proper but the package icon is set to default iconFerretti
Creating app bundle: Facewizz in c:\dev\repositories\profile_planner\profileplanner\target\dist\bundles Using custom package resource [application icon] (loaded from package/windows/Facewizz.ico on class path) is what I get. Seems your logging comes from the Maven plugin. The more abstractions you make from the original build tools, the more opportunities to fail imho.Informative
what version are you using of Java? I suddenly notice that when I build my app with the 7.0.17 the icon isn't set either. It is with the 7.0.12-ea release, so this was probably a bug that is going to be fixed in the bugfix release.Informative
see also here blogs.oracle.com/talkingjavadeployment/entry/… about fx:iconInformative
yes ,using java7.0.17 the blog gives the detail to be added into build.xml file as my project donot contain any build.xml file as I am using maven so project contain an pom.xml where its giving an error on tag <fx:deploy>Ferretti
you need to put the fx:deploy task in ant file (build.xml) and call it from your pom using the maven-antrun-plugin pluginInformative
i tried fx tags in pom.xml using ant. i have edited the post where i have added fx tags in maven-antrun-plugin but it wont give me custom package icon.Ferretti
you should try with the 7.0.12-ea releaseInformative
D
0
     you can do this:
      `<plugin>
            <groupId>com.zenjava</groupId>
            <artifactId>javafx-maven-plugin</artifactId>
            <version>8.8.3</version>
            <configuration>
                <vendor>YourCompany</vendor>
                <mainClass>com.alan344.MapperGenApplication</mainClass>
                <appName>mybatis-friend</appName>
                <bundleArguments>
                    <icon>${project.basedir}/src/main/resources/image/icon.ico</icon>
                </bundleArguments>
            </configuration>
        </plugin>`
Deconsecrate answered 21/8, 2019 at 7:40 Comment(1)
You should edit your question to add a minimal reproducible example demonstrating the problem.Withstand

© 2022 - 2024 — McMap. All rights reserved.