Oracle JDK/Windows, JPackage Error: Invalid or unsupported type: [exe]

Oracle JDK/Windows, JPackage Error: Invalid or unsupported type: [exe]

我正在尝试为 java 应用程序创建本机安装程序。我已经在 OpenJDK/Linux 上成功使用了 jpackage,但现在我在 Windows 上的 Oracle JDK 中。

我无法相信的是错误消息:如果帮助页面只是将其列为允许值之一,为什么 jpackage 声称 'exe' 是不受支持的类型?为什么输入 'app-image' 以外的任何内容都会导致失败?

我正在使用 maven-antrun-plugin 来执行这个 ant 片段:

        <target>
            <exec executable="jpackage" failonerror="true">
                <arg line="--version"/>
            </exec>
            <exec executable="jpackage" failonerror="true">
                <arg line="--help"/>
            </exec>
            <exec executable="jpackage" failonerror="true">
                <arg line="--input target/dist"/>
                <arg line="--main-jar ${project.artifactId}-${project.version}.jar"/>
                <arg line="--main-class ${mainclass}"/>
                <arg line="--dest target"/>
                <arg line="--name ${project.artifactId}"/>
                <arg line="--app-version ${project.version}"/>
                <arg line="--type exe"/>
                <arg line="--verbose"/>
            </exec>
        </target>

构建失败并显示此输出(三个任务分开)。

 [exec] 16.0.1


 [exec] Usage: jpackage <options>
 [exec] 
 [exec] Sample usages:
 [exec] --------------
 [exec]     Generate an application package suitable for the host system:
 [exec]         For a modular application:
 [exec]             jpackage -n name -p modulePath -m moduleName/className
 [exec]         For a non-modular application:
 [exec]             jpackage -i inputDir -n name \
 [exec]                 --main-class className --main-jar myJar.jar
 [exec]         From a pre-built application image:
 [exec]             jpackage -n name --app-image appImageDir
 [exec]     Generate an application image:
 [exec]         For a modular application:
 [exec]             jpackage --type app-image -n name -p modulePath \
 [exec]                 -m moduleName/className
 [exec]         For a non-modular application:
 [exec]             jpackage --type app-image -i inputDir -n name \
 [exec]                 --main-class className --main-jar myJar.jar
 [exec]         To provide your own options to jlink, run jlink separately:
 [exec]             jlink --output appRuntimeImage -p modulePath -m moduleName \
 [exec]                 --no-header-files [<additional jlink options>...]
 [exec]             jpackage --type app-image -n name \
 [exec]                 -m moduleName/className --runtime-image appRuntimeImage
 [exec]     Generate a Java runtime package:
 [exec]         jpackage -n name --runtime-image <runtime-image>
 [exec] 
 [exec] Generic Options:
 [exec]   @<filename> 
 [exec]           Read options and/or mode from a file 
 [exec]           This option can be used multiple times.
 [exec]   --type -t <type> 
 [exec]           The type of package to create
 [exec]           Valid values are: {"app-image", "exe", "msi"} 
 [exec]           If this option is not specified a platform dependent
 [exec]           default type will be created.
 [exec]   --app-version <version>
 [exec]           Version of the application and/or package
 [exec]   --copyright <copyright string>
 [exec]           Copyright for the application
 [exec]   --description <description string>
 [exec]           Description of the application
 [exec]   --help -h 
 [exec]           Print the usage text with a list and description of each valid
 [exec]           option for the current platform to the output stream, and exit
 [exec]   --name -n <name>
 [exec]           Name of the application and/or package
 [exec]   --dest -d <destination path>
 [exec]           Path where generated output file is placed
 [exec]           Defaults to the current working directory.
 [exec]           (absolute path or relative to the current directory)
 [exec]   --temp <file path>
 [exec]           Path of a new or empty directory used to create temporary files
 [exec]           (absolute path or relative to the current directory)
 [exec]           If specified, the temp dir will not be removed upon the task
 [exec]           completion and must be removed manually
 [exec]           If not specified, a temporary directory will be created and
 [exec]           removed upon the task completion.
 [exec]   --vendor <vendor string>
 [exec]           Vendor of the application
 [exec]   --verbose
 [exec]           Enables verbose output
 [exec]   --version
 [exec]           Print the product version to the output stream and exit
 [exec] 
 [exec] Options for creating the runtime image:
 [exec]   --add-modules <module name>[,<module name>...]
 [exec]           A comma (",") separated list of modules to add.
 [exec]           This module list, along with the main module (if specified)
 [exec]           will be passed to jlink as the --add-module argument.
 [exec]           if not specified, either just the main module (if --module is
 [exec]           specified), or the default set of modules (if --main-jar is 
 [exec]           specified) are used.
 [exec]           This option can be used multiple times.
 [exec]   --module-path -p <module path>...
 [exec]           A ; separated list of paths
 [exec]           Each path is either a directory of modules or the path to a
 [exec]           modular jar.
 [exec]           (each path is absolute or relative to the current directory)
 [exec]           This option can be used multiple times.
 [exec]   --jlink-options <jlink options> 
 [exec]           A space separated list of options to pass to jlink 
 [exec]           If not specified, defaults to "--strip-native-commands 
 [exec]           --strip-debug --no-man-pages --no-header-files" 
 [exec]           This option can be used multiple times.
 [exec]   --runtime-image <file path>
 [exec]           Path of the predefined runtime image that will be copied into
 [exec]           the application image
 [exec]           (absolute path or relative to the current directory)
 [exec]           If --runtime-image is not specified, jpackage will run jlink to
 [exec]           create the runtime image using options:
 [exec]           --strip-debug, --no-header-files, --no-man-pages, and
 [exec]           --strip-native-commands.
 [exec] 
 [exec] Options for creating the application image:
 [exec]   --icon <icon file path>
 [exec]           Path of the icon of the application package
 [exec]           (absolute path or relative to the current directory)
 [exec]   --input -i <input path>
 [exec]           Path of the input directory that contains the files to be packaged
 [exec]           (absolute path or relative to the current directory)
 [exec]           All files in the input directory will be packaged into the
 [exec]           application image.
 [exec] 
 [exec] Options for creating the application launcher(s):
 [exec]   --add-launcher <launcher name>=<file path>
 [exec]           Name of launcher, and a path to a Properties file that contains
 [exec]           a list of key, value pairs
 [exec]           (absolute path or relative to the current directory)
 [exec]           The keys "module", "main-jar", "main-class",
 [exec]           "arguments", "java-options", "app-version", "icon", and
 [exec]           "win-console" can be used.
 [exec]           These options are added to, or used to overwrite, the original
 [exec]           command line options to build an additional alternative launcher.
 [exec]           The main application launcher will be built from the command line
 [exec]           options. Additional alternative launchers can be built using
 [exec]           this option, and this option can be used multiple times to
 [exec]           build multiple additional launchers. 
 [exec]   --arguments <main class arguments>
 [exec]           Command line arguments to pass to the main class if no command
 [exec]           line arguments are given to the launcher
 [exec]           This option can be used multiple times.
 [exec]   --java-options <java options>
 [exec]           Options to pass to the Java runtime
 [exec]           This option can be used multiple times.
 [exec]   --main-class <class name>
 [exec]           Qualified name of the application main class to execute
 [exec]           This option can only be used if --main-jar is specified.
 [exec]   --main-jar <main jar file>
 [exec]           The main JAR of the application; containing the main class
 [exec]           (specified as a path relative to the input path)
 [exec]           Either --module or --main-jar option can be specified but not
 [exec]           both.
 [exec]   --module -m <module name>[/<main class>]
 [exec]           The main module (and optionally main class) of the application
 [exec]           This module must be located on the module path.
 [exec]           When this option is specified, the main module will be linked
 [exec]           in the Java runtime image.  Either --module or --main-jar
 [exec]           option can be specified but not both.
 [exec] 
 [exec] Platform dependent option for creating the application launcher:
 [exec]   --win-console
 [exec]           Creates a console launcher for the application, should be
 [exec]           specified for application which requires console interactions
 [exec] 
 [exec] Options for creating the application package:
 [exec]   --app-image <file path>
 [exec]           Location of the predefined application image that is used
 [exec]           to build an installable package
 [exec]           (absolute path or relative to the current directory)
 [exec]   --file-associations <file path>
 [exec]           Path to a Properties file that contains list of key, value pairs
 [exec]           (absolute path or relative to the current directory)
 [exec]           The keys "extension", "mime-type", "icon", and "description"
 [exec]           can be used to describe the association.
 [exec]           This option can be used multiple times.
 [exec]   --install-dir <file path>
 [exec]           Relative sub-path under the default installation location
 [exec]   --license-file <file path>
 [exec]           Path to the license file
 [exec]           (absolute path or relative to the current directory)
 [exec]   --resource-dir <path>
 [exec]           Path to override jpackage resources
 [exec]           Icons, template files, and other resources of jpackage can be
 [exec]           over-ridden by adding replacement resources to this directory.
 [exec]           (absolute path or relative to the current directory)
 [exec]   --runtime-image <file-path>
 [exec]           Path of the predefined runtime image to install
 [exec]           (absolute path or relative to the current directory)
 [exec]           Option is required when creating a runtime package.
 [exec] 
 [exec] Platform dependent options for creating the application package:
 [exec]   --win-dir-chooser
 [exec]           Adds a dialog to enable the user to choose a directory in which
 [exec]           the product is installed
 [exec]   --win-menu
 [exec]           Adds the application to the system menu
 [exec]   --win-menu-group <menu group name>
 [exec]           Start Menu group this application is placed in
 [exec]   --win-per-user-install
 [exec]           Request to perform an install on a per-user basis
 [exec]   --win-shortcut
 [exec]           Creates a desktop shortcut for the application
 [exec]   --win-upgrade-uuid <id string>
 [exec]           UUID associated with upgrades for this package


 [exec] [22:46:46.538] Can not find WiX tools (light.exe, candle.exe)
 [exec] [22:46:46.529] Running candle.exe
 [exec] [22:46:46.538] Download WiX 3.0 or later from https://wixtoolset.org and add it to the PATH.
 [exec] [22:46:46.539] jdk.jpackage.internal.PackagerException: Error: Invalid or unsupported type: [exe]
 [exec]     at jdk.jpackage/jdk.jpackage.internal.Arguments.generateBundle(Arguments.java:658)
 [exec]     at jdk.jpackage/jdk.jpackage.internal.Arguments.processArguments(Arguments.java:538)
 [exec]     at jdk.jpackage/jdk.jpackage.main.Main.execute(Main.java:98)
 [exec]     at jdk.jpackage/jdk.jpackage.main.Main.main(Main.java:52)

那么为什么我会收到该错误?我该如何解决?

看来误导性错误消息的解决方案 错误:无效或不受支持的类型:[exe] 一直在屏幕上:

[exec] [22:46:46.538] Can not find WiX tools (light.exe, candle.exe)
[exec] [22:46:46.529] Running candle.exe
[exec] [22:46:46.538] Download WiX 3.0 or later from https://wixtoolset.org and
add it to the PATH.

在完全按照 jpackage 的要求执行之后,现在它的表现好多了。