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..

user1859806
  • 213
  • 1
  • 2
  • 8

3 Answers3

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!

gaeste
  • 146
  • 6
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)

Nicolas Mommaerts
  • 3,207
  • 4
  • 35
  • 55
  • 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 icon – user1859806 Apr 10 '13 at 12:58
  • 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. – Nicolas Mommaerts Apr 10 '13 at 16:39
  • 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. – Nicolas Mommaerts Apr 10 '13 at 16:50
  • see also here https://blogs.oracle.com/talkingjavadeployment/entry/packaging_improvements_in_jdk_7 about fx:icon – Nicolas Mommaerts Apr 10 '13 at 18:58
  • 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 – user1859806 Apr 12 '13 at 08:53
  • you need to put the fx:deploy task in ant file (build.xml) and call it from your pom using the maven-antrun-plugin plugin – Nicolas Mommaerts Apr 13 '13 at 13:23
  • 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. – user1859806 Apr 16 '13 at 07:22
  • you should try with the 7.0.12-ea release – Nicolas Mommaerts Apr 17 '13 at 08:20
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>`
Alan Sun
  • 1
  • 1
  • You should [edit](https://stackoverflow.com/posts/57247918/edit) your question to add a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example) demonstrating the problem. – Mebin Joe Aug 21 '19 at 07:42