How to set custom icon for javafx native package i

2019-01-25 11:07发布

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

2条回答
Evening l夕情丶
2楼-- · 2019-01-25 11:47

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!

查看更多
爷、活的狠高调
3楼-- · 2019-01-25 11:49

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)

查看更多
登录 后发表回答