1

My pom includes the itext7-core artifact.

    <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 And module-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;
}

The program from the IDE works fine. After javafx:jlink:

Can't extract module name from itext7-core-7.2.0.pom: Only outputDirectories and jars are accepted on the path Some dependencies encountered issues while attempting to be resolved as modules and will not be included in the classpath; you can change this behavior via the 'includePathExceptionsInClasspath' configuration parameter. Required filename-based automodules detected. Please don't publish this project to a public artifact repository! All logs:

[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)

Now I have used JPackageScriptFX as jewelsea said (thanks). But after installing 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
Fezas
  • 21
  • 5
  • jlink doesn’t create packages, it creates images. jpackage creates packages. What are you trying to do? – jewelsea Jan 23 '22 at 16:09
  • publish my application written in JDK 16 – Fezas Jan 23 '22 at 21:49
  • Publish it packaged in what format, to where, to whom and how? If you want help, you have to provide info useful to somebody who may wish to help you. Why are you using jlink instead of jpackage? – jewelsea Jan 23 '22 at 21:55
  • Please provide a [mcve] and replace the text after “After javafx:jlink” with the full build output formatted as code, like was done in [Error message when trying to run javafx application in netbeans using maven](https://stackoverflow.com/questions/57403131/error-message-when-trying-to-run-javafx-application-in-netbeans-using-maven). – jewelsea Jan 24 '22 at 00:40
  • I think you dependency management is wrong. I don’t think you place dependencies on pom types in that section, instead place the dependency info in the dependencyManagement section with a scope of import. See [Maven dependency management](https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#importing-dependencies). – jewelsea Jan 24 '22 at 00:54
  • Consider replacing the pom import with [only the modules you need](https://kb.itextpdf.com/home/it7kb/installation-guidelines/installing-itext-7-for-java). If the itext jars do not include required module-info in them to support jlink, then you will need to file a support request with the product provider to request that be added if you want to use jlink. You can package non modular dependencies using jpackage instead of jlink, see https://github.com/dlemmermann/JPackageScriptFX – jewelsea Jan 24 '22 at 01:09
  • The maven log you added shows that you have numerous issues, besides fixing the dependencyManagement for itext. The slf4j version you are using is not modular and is not compatible with jlink. You can [hack it](https://stackoverflow.com/questions/47727869/creating-module-info-for-automatic-modules-with-jdeps-in-java-9), to make at least some of the dependencies work, but you would might be better off using JPackageScriptFX to package as a non-modular app. – jewelsea Jan 24 '22 at 22:56
  • it is kind of a different question now, so perhaps should be asked as a new question. It can't find `java/sql/SQLException`. That class is in the `java.sql` package (which also the `java.sql` module), which is part of the jdk. You can see that there is jmod for it in the jmod directory of the JDK. Ensure your JAVA_HOME is set correctly to the JDK directory, then the packaging tools will find it (see [jlink man page --module-path option to understand how that works](https://www.mankier.com/1/jlink-java-17#Jlink_Options)). – jewelsea Jan 26 '22 at 05:56
  • [JPackageScriptFX](https://github.com/dlemmermann/JPackageScriptFX) can work with a non-modular project for your code and some of the dependent libraries. But some of the libraries should that are modular (e.g. stuff from the JDK) should be loaded as modules rather the classpath. The tool tries to automate through `jdeps`, but the automation is not perfect. You can manually add the modules it didn't find, see JPackageScriptFX doc on `manual_modules`, you can try `manual_modules=,java.sql` for this or other things it misses. I have not tried this, so do not know that it will work. – jewelsea Jan 26 '22 at 06:03
  • I advise starting small rather than trying to package your entire app. Start with the example project in JPackageScriptFX, ensure that it packages and deploys to your satisfaction and that this is the right distribution approach for your app. Then gradually add in the libaries that you need to the packaging one at a time, using a dummy app to adding minimal test code for each library just as a sanity check as you add it, to make sure it doesn't break the build. Once you can build a package with all required libraries, add in all your code and test your packaged app. – jewelsea Jan 26 '22 at 06:10

1 Answers1

0

The solution with JPackageScriptFX is the best. Thanks Jewelsea. Jmods from javafx copied to C:/jdk/jmods. Then in bat file

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

I finally got a working application weighing only 100 MB:)!

Fezas
  • 21
  • 5