4

使用 JPackage,我无法让 --win-console 选项为主启动器分开工作,但我希望主启动器不输出到控制台,但有一个调试版本可以。

即如果我跑

jpackage --add-launcher SongKongDebug=jpackage.properties @jpackage.txt 

jpackage.txt

-i C:\Code\jthink\SongKong\target\songkong-6.10
--runtime-image C:\code\jthink\songkong\JVM64
--main-class com.jthink.songkong.cmdline.SongKong
--name SongKong
--win-dir-chooser
--main-jar lib\SongKong-6.10.jar
--app-version 6.10
--install-dir Jthink\SongKong
--copyright "Copyright 2020 JThink Ltd, United Kingdom"
--license-file C:\Code\jthink\SongKong\src\main\scripts\license.txt
--java-options "-Dhttps.protocols=TLSv1.1,TLSv1.2"
--java-options "--add-opens java.base/java.lang=ALL-UNNAMED"
--java-options "-XX:MaxRAMPercentage=75.0"
--java-options "-XX:MetaspaceSize=45 "
--java-options "-Dcom.mchange.v2.log.MLog=com.mchange.v2.log.jdk14logging.Jdk14MLog"
--java-options "-Dorg.jboss.logging.provider=jdk"
--java-options "-Djava.util.logging.config.class=com.jthink.songkong.logging.StandardLogging"
--vendor JThink
--win-menu
--win-shortcut
--win-menu-group Jthink

jpackage.properties

win-console=--win-console

然后 SongKong 和 SongKongDebug 都在没有控制台的情况下运行

我还尝试将 jpackage.properties (这意味着名称/值对)修改为

--win-console

它仍然没有工作

而如果我添加

--win-console 

到 jpackage.txt 和

win-console 

到 jpackage.properties

那么SongKong将作为控制台运行,而SongKongDebug不会,但对我来说是错误的方式。

如果我将SongKong重命名为SongKongDebug并将SongKongDebug重命名为SongKong

例如

jpackage --add-launcher SongKong=jpackage.properties @jpackage.txt

并修改 set --name SongKongDebug

在 jpackage.txt

然后它可以工作,但是现在在安装 SongKong 时它说安装SongKongDebug这是错误的。

我已经尝试过当前的 Java 14 版本和早期访问 Java 15 和 16 版本,但没有区别。

我发现报告了这个错误,但随后用户将其关闭为没问题https://bugs.openjdk.java.net/browse/JDK-8213717我发现 jpackage 帮助有点混乱所以我想知道我是否做错了方法。

帮助说

创建应用程序启动器的选项:

--add-launcher 启动器名称=文件路径

Name of launcher, and a path to a Properties file that contains a list of key, value pairs (absolute path or relative to the current

目录)。

The keys "module", "add-modules", "main-jar", "main-class", "arguments", "java-options", "app-version", "icon", and "win-console"

可以使用。

These options are added to, or used to overwrite, the original command line options to build an additional alternative launcher. The

主应用程序启动器将从命令行选项构建。可以使用此选项构建其他替代启动器,并且可以多次使用此选项来构建多个附加启动器。--arguments 主类参数

Command line arguments to pass to the main class if no command line arguments are given to the launcher.

This option can be used multiple times.

--java-options java 选项

Options to pass to the Java runtime.

This option can be used multiple times.

--main-class 类名

Qualified name of the application main class to execute.

This option can only be used if --main-jar is specified.

--main-jar 主jar文件

The main JAR of the application; containing the main class (specified as a path relative to the input path).

Either --module or --main-jar option can be specified but not both.

--module 或 -m 模块名称/主类]

The main module (and optionally main class) of the application This module must be located on the module path.

When this option is specified, the main module will be linked in the Java runtime image. Either --module or --main-jar option can be

指定但不是两者。

因此,您可以使用 --add-launcher 创建附加启动器并使用属性文件,但这也听起来您可以将额外参数作为附加命令行选项传递,但这怎么可能,因为不清楚哪个启动器他们指的是?

4

1 回答 1

1

您可以使用or为每个--add-launcher属性文件 指定控制台选项:win-console=truewin-console=false

jpackage.properties

 # This adds console for the current launcher:
 win-console=true

在命令行或参数文件中,主应用程序和所有未指定的文件的控制台上@jpackage.txt的标志切换:--win-console--add-launcherwin-console=true|false

@jpackage.txt

# This adds console for all applications:
--win-console

不幸的是,jpackage 有错误JDK-8253426,它阻止了在 JDK15 中--add-launcher使用不同main-class=xyz的设置。

于 2020-07-11T11:36:37.737 回答