图标 – 如何在Windows上为javafx本机程序包图标设置自定义图标

前端之家收集整理的这篇文章主要介绍了图标 – 如何在Windows上为javafx本机程序包图标设置自定义图标前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在尝试创建exe文件的图标,同时创建javafx包装的本机捆绑.
我尝试将图标添加到pom.xml中,但直到它不会为我工作,因为它提供了默认图标
使用包含Pom.xml的Intellij IDEA IDE,通过command = mvn jfx:build-native创建包
这是我的pom.xml:
  1. <build>
  2. <plugins>
  3. <plugin>
  4. <groupId>com.zenjava</groupId>
  5. <artifactId>javafx-maven-plugin</artifactId>
  6. <version>1.5</version>
  7. <configuration>
  8.  
  9. <mainClass>com.demoApp.testapp.testApplication</mainClass>
  10.  
  11. <!-- only required if signing the jar file -->
  12. <keyStoreAlias>example-user</keyStoreAlias>
  13. <keyStorePassword>example-password</keyStorePassword>
  14. <permissions>
  15. <permission>all-permissions</permission>
  16. </permissions>
  17. <icon>${basedir}/src/main/resources/images/logoIcon.ico</icon>
  18. </configuration>
  19. </plugin>
  20. <plugin>
  21. <groupId>org.apache.maven.plugins</groupId>
  22. <artifactId>maven-compiler-plugin</artifactId>
  23. <configuration>
  24. <source>1.7</source>
  25. <target>1.7</target>
  26. </configuration>
  27. </plugin>
  28.  
  29. </plugins>
  30. </build>

我在pom.xml中添加了一个图标路径${basedir} /src/main/resources/images/logoIcon.ico
将在本机程序包执行时运行,但它不适合我

还有其他办法吗?
请建议.

我使用ant在pom.xml中尝试了fx标签,这是我在pom.xml中的更改

  1. <properties>
  2.  
  3. <javafx.tools.ant.jar>${env.JAVA_HOME}\lib\ant-javafx.jar</javafx.tools.ant.jar> </properties>
  4.  
  5.  
  6. <plugin>
  7. <artifactId>maven-antrun-plugin</artifactId>
  8. <version>1.6</version>
  9. <executions>
  10. <execution>
  11. <id>create-launcher-jar</id>
  12. <phase>package</phase>
  13. <goals>
  14. <goal>run</goal>
  15. </goals>
  16. <configuration>
  17. <target xmlns:fx="javafx:com.sun.javafx.tools.ant">
  18. <taskdef
  19. uri="javafx:com.sun.javafx.tools.ant"
  20. resource="com/sun/javafx/tools/ant/antlib.xml"
  21. classpath="${javafx.tools.ant.jar}"/>
  22. <fx:application id="fxApp"
  23. name="${project.name}"
  24. mainClass="com.precisionhawk.flightplanner.FlightPlannerApp"/>
  25. <fx:jar destfile="${project.build.directory}/${project.build.finalName}-launcher">
  26. <fx:application refid="fxApp"/>
  27. <fx:fileset dir="${project.build.directory}/classes"/>
  28. </fx:jar>
  29. <attachartifact file="${project.build.directory}/${project.build.finalName}-launcher.jar"
  30. classifier="launcher"/>
  31. <fx:deploy>
  32. <fx:info>
  33. <fx:icon href="${basedir}/src/main/deploy/logoIcon.ico"></fx:icon>
  34. </fx:info>
  35.  
  36. </fx:deploy>
  37. </target>
  38. </configuration>
  39. </execution>
  40. </executions>
  41. </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相关文章