无法使用 jlink 创建包

Unable to create package with jlink

我的 pom 包含 itext7-core 工件。

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <junit.version>5.7.1</junit.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-controls</artifactId>
            <version>18-ea+7</version>
            .....
        </dependency>
        <dependency>
            <groupId>com.itextpdf</groupId>
            <artifactId>itext7-core</artifactId>
            <version>7.2.0</version>
            <type>pom</type>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.openjfx</groupId>
                <artifactId>javafx-maven-plugin</artifactId>
                <version>0.0.8</version>
                <configuration>
                    <stripDebug>true</stripDebug>
                    <compress>2</compress>
                    <noHeaderFiles>true</noHeaderFiles>
                    <noManPages>true</noManPages>
                    <launcher>parallel</launcher>
                    <jlinkImageName>parallel</jlinkImageName>
                    <jlinkZipName>parallel</jlinkZipName>
                    <mainClass>com.tusur.parallel.Start</mainClass>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
                <configuration>
                    <source>15</source>
                    <target>15</target>
                </configuration>
            </plugin>
        </plugins>
    </build>

enter image description here 和模块-info.java

module fezas.telegra {
    requires javafx.controls;
    requires javafx.fxml;
    requires javafx.web;

    requires java.sql;
    requires kernel;
    requires barcodes;
    requires commons;
    requires io;
    requires pdfa;
    requires forms;
    requires styled.xml.parser;
    requires hyph;
    requires svg;
    requires sign;
    requires layout;
    requires html2pdf;
    requires org.slf4j;
    requires org.apache.commons.io;
    requires java.desktop;
    requires jdk.jsobject;
    requires ckeditor;
    requires com.google.zxing;
    requires com.google.zxing.javase;

    opens fezas.telegra to javafx.fxml;
    opens fezas.telegra.controllers to javafx.fxml;
    opens fezas.telegra.entity to javafx.fxml;

    exports fezas.telegra;
    exports fezas.telegra.controllers;
    exports fezas.telegra.dao;
    exports fezas.telegra.util;
    exports fezas.telegra.entity;
}

IDE 中的程序工作正常。 javafx:jlink之后:

无法从 itext7-core-7.2 中提取模块名称。0.pom: 路径上只接受 outputDirectories 和 jars 某些依赖项在尝试作为模块解析时遇到问题,并且不会包含在类路径中;您可以通过 'includePathExceptionsInClasspath' 配置参数更改此行为。 检测到必需的基于文件名的自动模块。请不要将此项目发布到 public 工件存储库! 所有日志:

[INFO] 
[INFO] ---------------------------< fezas:telegra >----------------------------
[INFO] Building telegra 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ telegra ---
[INFO] Deleting C:\Users\Fezas\telegra\target
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ telegra ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 44 resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ telegra ---
[WARNING] Can't extract module name from itext7-core-7.2.0.pom: zip END header not found
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 62 source files to C:\Users\Fezas\telegra\target\classes
[INFO] /C:/Users/Fezas/telegra/src/main/java/fezas/telegra/util/EditCell.java: C:\Users\Fezas\telegra\src\main\java\fezas\telegra\util\EditCell.java uses unchecked or unsafe operations.
[INFO] /C:/Users/Fezas/telegra/src/main/java/fezas/telegra/util/EditCell.java: Recompile with -Xlint:unchecked for details.
[INFO] 
[INFO] >>> javafx-maven-plugin:0.0.8:jlink (default-cli) > process-classes @ telegra >>>
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ telegra ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 44 resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ telegra ---
[WARNING] Can't extract module name from itext7-core-7.2.0.pom: zip END header not found
[WARNING] *********************************************************************************************************************************************************************************************************************************************************************************************************************************************************************
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 62 source files to C:\Users\Fezas\telegra\target\classes
[INFO] /C:/Users/Fezas/telegra/src/main/java/fezas/telegra/util/EditCell.java: C:\Users\Fezas\telegra\src\main\java\fezas\telegra\util\EditCell.java uses unchecked or unsafe operations.
[INFO] /C:/Users/Fezas/telegra/src/main/java/fezas/telegra/util/EditCell.java: Recompile with -Xlint:unchecked for details.
[INFO] 
[INFO] <<< javafx-maven-plugin:0.0.8:jlink (default-cli) < process-classes @ telegra <<<
[INFO] 
[INFO] 
[INFO] --- javafx-maven-plugin:0.0.8:jlink (default-cli) @ telegra ---
[WARNING] There are 1 pathException(s). The related dependencies will be ignored.
   - exception: Only outputDirectories and jars are accepted on the path
[WARNING] Can't extract module name from itext7-core-7.2.0.pom: Only outputDirectories and jars are accepted on the path
Error: automatic module cannot be used with jlink: org.slf4j from file:///C:/Users/Fezas/.m2/repository/org/slf4j/slf4j-api/1.7.32/slf4j-api-1.7.32.jar
[ERROR] Command execution failed.
org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1)
    at org.apache.commons.exec.DefaultExecutor.executeInternal (DefaultExecutor.java:404)
    at org.apache.commons.exec.DefaultExecutor.execute (DefaultExecutor.java:166)
    at org.openjfx.JavaFXBaseMojo.executeCommandLine (JavaFXBaseMojo.java:567)
    at org.openjfx.JavaFXBaseMojo.executeCommandLine (JavaFXBaseMojo.java:434)
    at org.openjfx.JavaFXJLinkMojo.execute (JavaFXJLinkMojo.java:209)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:64)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:564)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
    at org.codehaus.classworlds.Launcher.main (Launcher.java:47)
org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1)
    at org.apache.commons.exec.DefaultExecutor.executeInternal(DefaultExecutor.java:404)
    at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:166)
    at org.openjfx.JavaFXBaseMojo.executeCommandLine(JavaFXBaseMojo.java:567)
    at org.openjfx.JavaFXBaseMojo.executeCommandLine(JavaFXBaseMojo.java:434)
    at org.openjfx.JavaFXJLinkMojo.execute(JavaFXJLinkMojo.java:209)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:957)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:289)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:193)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:564)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:347)
    at org.codehaus.classworlds.Launcher.main(Launcher.java:47)

现在我已经像jewelsea所说的那样使用了JPackageScriptFX(谢谢)。但是安装msi后

C:\Users\Fezas\JPackageScriptFX>JPackageScriptFX.exe
Exception in thread "main" java.lang.NoClassDefFoundError: java/sql/SQLException
        at fezas.telegra.TelegraStart.main(TelegraStart.java:5)
Caused by: java.lang.ClassNotFoundException: java.sql.SQLException
        at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(Unknown Source)
        at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(Unknown Source)
        at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
        ... 1 more
Failed to launch JVM

JPackageScriptFX 的解决方案是最好的。谢谢珠宝海。 Jmods 从 javafx 复制到 C:/jdk/jmods。 然后在bat文件中

set manual_modules=,jdk.crypto.ec,jdk.localedata,javafx.controls,javafx.fxml,javafx.web,java.sql

我终于得到了一个只有 100 MB 的可用应用程序:)!