3

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

Allan Juan
  • 2,048
  • 1
  • 18
  • 42

1 Answers1

4

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.

mipa
  • 10,369
  • 2
  • 16
  • 35
  • 2
    icon16 ... are instances of Image, so the original icon can be anything you can load into an image. Normally PNGs are used for this purpose. – mipa Aug 26 '20 at 13:56