How to change the window icon of a JPackage app on Windows?

Viewed 424

I'm deploying a self-contained application with JPackage. This is how I compile it for Windows:

call "%JAVA_HOME%\bin\jpackage" ^
  --type %INSTALLER_TYPE% ^
  --dest target/installer ^
  --input target/installer/input/libs ^
  --name Deshopp ^
  --main-class com.app.AppLauncher ^
  --main-jar %MAIN_JAR% ^
  --java-options -Xmx2048m ^
  --runtime-image target/java-runtime ^
  --app-version %APP_VERSION% ^
  --icon src/main/logo/windows/logo.ico ^
  --vendor "ACME Inc." ^
  --copyright "Copyright © 2019-20 ACME Inc." ^
  --win-dir-chooser ^
  --win-shortcut ^
  --win-per-user-install ^
  --win-menu

But how do I use a custom icon for the application header/window, instead of Windows' default one depicted below?

Screenshot depicting the app's header with a Windows default icon

1 Answers

In addition to the platform specific icon which you specify in the jpackage call, you also have to specify icons in the start method of your main class like this

primaryStage.getIcons().addAll(icon16, icon32, icon64, icon128);

where icon16, ... are icons for your application with the corresponding sizes.

Related