我试图在创建javafx打包的本地捆绑时改变exe文件的图标。我试着在pom.xml中添加图标,但直到它不能为我工作,因为它给出了默认图标
使用Intellij IDEA IDE,其中包含一个Pom.xml创建包由command = mvn jfx:build-native
这是我的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>
我已经添加了一个图标路径到pom.xml ${basedir}/src/main/resources/images/logoIcon.ico当本机包执行时,它会运行但它不会为我工作
还有别的方法吗?请建议。
我尝试fx标签在pom.xml使用ant,这是我的变化在pom.xml
<properties>
<javafx.tools.ant.jar>${env.JAVA_HOME}libant-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>
我刚刚在使用Zonsky的伟大javafx-maven-plugin时遇到了同样的问题。从1.5版本开始,src/main/deploy目录将被添加到类路径中。您想要使用的图标可以添加到那里,它将在本地构建器的类路径中可用!
我添加了src/main/deploy/package/windows/myapp.ico,它终于工作了:)
:
- 创建
src/main/deploy/package/windows/
文件夹 - 添加名为
${project.build.finalName}.ico
的图标 - 运行
mvn jfx:build-native
我没有广泛地玩它-只是得到它的工作,并想分享。如果你想用不同名字的图标,我不知道怎么做。至少现在还没有。在配置部分的<icon>...</icon>
部分似乎是webstart,所以我一直没有使用它。希望你能成功!
你需要在构建原生应用时查看日志记录。这将告诉你安装程序在哪里查找图标文件以及使用哪个名称。对于默认的Windows原生应用,它在。/package/Windows/'appname'.ico中查找不记得"appname"来自哪里,但只要在构建时查看日志,它就会告诉你。
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>`