Include icon in Self-Contained JavaFX application

前端 未结 4 680
深忆病人
深忆病人 2020-12-15 12:51

I\'ve been fighting with this for over a day and have read many posts on SO and other places, but I\'m still having problems.

I need to include my application icon i

4条回答
  •  醉酒成梦
    2020-12-15 12:56

    For folks who are already using Maven to build a jar, building a native app and including an icon is easy with the javafx-maven-plugin. (I found it via this answer.)

    The plugin developers have provided a nice little auto-configuration script. I had to add a key, but then everything worked smoothly.

    Once you have that working, all you have to do to get a custom icon is create a correctly-formatted file, give it exactly the same name as the native app, and drop it in the correct folder for the given system:

    • Windows: put some ICO-file at src/main/deploy/package/windows/{appname}.ico, where {appname} is the configured appname of your application
    • Mac OS(X): put some ICNS-file at src/main/deploy/package/macosx/{appname}.icns, where {appname} is the configured appname of your application
    • Linux: put some PNG-file at src/main/deploy/package/linux/{appname}.png, where {appname} is the configured appname of your application

    (The text above was copied from this issue.)

    I've tested this on both Windows and Mac, and it works in both cases.

提交回复
热议问题