openjfx / javafx-maven-plugin

Maven plugin to run JavaFX 11+ applications
Apache License 2.0
371 stars 59 forks source link

Can't run jlink goal on Windows. #133

Closed dpkg-i-foo-deb closed 3 years ago

dpkg-i-foo-deb commented 3 years ago

This plugin is hella useful but I tried to run the jlink goal on a Windows virtual machine to test if it worked and I'm facing the following error:

Error: Module java.base not found, required by co.edu.uniquindio.banco.application
java.lang.module.FindException: Module java.base not found, required by co.edu.uniquindio.banco.application
    at java.base/java.lang.module.Resolver.findFail(Resolver.java:900)
    at java.base/java.lang.module.Resolver.resolve(Resolver.java:191)
    at java.base/java.lang.module.Resolver.resolve(Resolver.java:140)
    at java.base/java.lang.module.Configuration.resolve(Configuration.java:421)
    at java.base/java.lang.module.Configuration.resolve(Configuration.java:255)
    at jdk.jlink/jdk.tools.jlink.internal.Jlink$JlinkConfiguration.resolve(Jlink.java:217)
    at jdk.jlink/jdk.tools.jlink.internal.JlinkTask.createImageProvider(JlinkTask.java:489)
    at jdk.jlink/jdk.tools.jlink.internal.JlinkTask.createImage(JlinkTask.java:399)
    at jdk.jlink/jdk.tools.jlink.internal.JlinkTask.run(JlinkTask.java:271)
    at jdk.jlink/jdk.tools.jlink.internal.Main.run(Main.java:54)
    at jdk.jlink/jdk.tools.jlink.internal.Main.main(Main.java:33)
[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 java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:567)
    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)
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:78)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:567)
    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)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  4.898 s
[INFO] Finished at: 2021-07-13T21:00:02-05:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.openjfx:javafx-maven-plugin:0.0.6:jlink (default-cli) on project Banco: Error: Command execution failed. Process exited with an error: 1 (Exit value: 1) -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

The javafx:run goal works as expected but I cannot get the jlink to work...

This is the javafx plugin pom fragment:

</configuration>
        </plugin>
        <plugin>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-maven-plugin</artifactId>
            <version>0.0.6</version>
            <configuration>
                <stripDebug>true</stripDebug>
                <compress>2</compress>
                <noHeaderFiles>true</noHeaderFiles>
                <noManPages>true</noManPages>
                <launcher>banco</launcher>
                <jlinkImageName>Banco</jlinkImageName>
                <jlinkZipName>BancoZip</jlinkZipName>
                <mainClass>co.edu.uniquindio.banco.application.App</mainClass>
batuhanyilmazer commented 3 years ago

I did not use to get same error, but it started after trying a plugin named "fxlauncher". I tried but it did not work, so I undid changes, even I had created a new branch for testing. As I said, I undid changes but still getting error. javafx:run works fine, but javafx:jlink does not. here's my pom:


        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-controls</artifactId>
            <version>16</version>
        </dependency>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-fxml</artifactId>
            <version>16</version>
        </dependency>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-base</artifactId>
            <version>16</version>
        </dependency>
        <dependency>
            <groupId>xyz.ylmzr</groupId>
            <artifactId>mathlib</artifactId>
            <version>1.1.1</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
            </plugin>
            <plugin>
                <groupId>org.openjfx</groupId>
                <artifactId>javafx-maven-plugin</artifactId>
                <version>0.0.6</version>
                <configuration>
                    <mainClass>xyz.ylmzr.App</mainClass>
                    <launcher>start</launcher>
                </configuration>
            </plugin>
        </plugins>
    </build>```
YovelB commented 3 years ago

You need to further configure your pom file in order to run javafx:jlink. You can refer to the documentation in: https://github.com/openjfx/javafx-maven-plugin.

You can even find JavaFX samples for gradle/maven in: https://github.com/openjfx/samples.

Note: It's not needed to add javafx-base dependency as it is already added by javafx-controls dependency.

batuhanyilmazer commented 3 years ago

You need to further configure your pom file in order to run javafx:jlink. You can refer to the documentation in: https://github.com/openjfx/javafx-maven-plugin.

You can even find JavaFX samples for gradle/maven in: https://github.com/openjfx/samples.

Note: It's not needed to add javafx-base dependency as it is already added by javafx-controls dependency.

I don't understand Error messages so much but I can clearly say that he needs javafx.base, because the first line of error message says Error: Module java.base not found, required by co.edu.uniquindio.banco.application Also I configured my pom correctly and completely (If you are talking to me), as I said, It was working before trying launcherfx plugin.

YovelB commented 3 years ago

That error usually refers to Modular projects where you need to create a module-info file like so:

 module hellofx {
    requires javafx.controls;
    requires javafx.fxml;

    opens org.openjfx to javafx.fxml;
    exports org.openjfx;
}

The sample project can be found here: https://github.com/openjfx/samples/tree/master/IDE/IntelliJ/Modular/Maven.

Also, can you be more clear about which launcherfx plugin you are referring to?

dpkg-i-foo-deb commented 3 years ago

That error usually refers to Modular projects where you need to create a module-info file like so:

 module hellofx {
    requires javafx.controls;
    requires javafx.fxml;

    opens org.openjfx to javafx.fxml;
    exports org.openjfx;
}

The sample project can be found here: https://github.com/openjfx/samples/tree/master/IDE/IntelliJ/Modular/Maven.

Also, can you be more clear about which launcherfx plugin you are referring to?

Eh I already have my module-info configured, the jlink goal works on Linux but it doesn't work on Windows, that is the problem.

YovelB commented 3 years ago

I suggest you try running the maven samples as a test or try using the official JLink plugin as the maven JLink functionality for javafx-maven-plugin is being deprecated according to #131.

dpkg-i-foo-deb commented 3 years ago

I suggest you try running the maven samples as a test or try using the official JLink plugin as the maven JLink functionality for javafx-maven-plugin is being deprecated according to #131.

I already tried the samples, same error on Windows.

Error: Module java.base not found, required by hellofx
java.lang.module.FindException: Module java.base not found, required by hellofx
    at java.base/java.lang.module.Resolver.findFail(Resolver.java:900)
    at java.base/java.lang.module.Resolver.resolve(Resolver.java:191)
    at java.base/java.lang.module.Resolver.resolve(Resolver.java:140)
    at java.base/java.lang.module.Configuration.resolve(Configuration.java:421)
    at java.base/java.lang.module.Configuration.resolve(Configuration.java:255)
    at jdk.jlink/jdk.tools.jlink.internal.Jlink$JlinkConfiguration.resolve(Jlink.java:217)
    at jdk.jlink/jdk.tools.jlink.internal.JlinkTask.createImageProvider(JlinkTask.java:489)
    at jdk.jlink/jdk.tools.jlink.internal.JlinkTask.createImage(JlinkTask.java:399)
    at jdk.jlink/jdk.tools.jlink.internal.JlinkTask.run(JlinkTask.java:271)
    at jdk.jlink/jdk.tools.jlink.internal.Main.run(Main.java:54)
    at jdk.jlink/jdk.tools.jlink.internal.Main.main(Main.java:33)
[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 java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:567)
    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)
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:78)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:567)
    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)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  3.539 s
[INFO] Finished at: 2021-07-17T11:30:30-05:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.openjfx:javafx-maven-plugin:0.0.6:jlink (default-cli) on project hellofx: Error: Command execution failed. Process exited with an error: 1 (Exit value: 1) -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
batuhanyilmazer commented 3 years ago

JavaFX doesn't have a future compared to other languages/frameworks I advise you to leave Java and start learning C#, I know you may not want to learn a new language because It takes time and effort; I used to think that byt after trying C# I understood that I made a true decision. Here's major reasons to use C#:

If you think learning C#, I can suggest MSDN (Microsoft Developer Network) as Docs and Jetbrains Rider (It is paid except for students, but you can use Visual Studio Community which is free and popular). Have a good day!

dpkg-i-foo-deb commented 3 years ago

JavaFX doesn't have a future compared to other languages/frameworks I advise you to leave Java and start learning C#, I know you may not want to learn a new language because It takes time and effort; I used to think that byt after trying C# I understood that I made a true decision. Here's major reasons to use C#:

* It is extremely similar to Java, I can say that Variable declarations, Operators, Loops, if-statements and Methods are exact same.

* It has a great compiler, It can compile to all in one .exe out of the box. That's important for me because I searched for a way to package&distribute JavaFX application for 2 weeks, at the end, I found a way but that was taking so long to build. So C# is extremely easy to distribute.

* Microsoft supports C# and develop it actively.

If you think learning C#, I can suggest MSDN (Microsoft Developer Network) as Docs and Jetbrains Rider (It is paid except for students, but you can use Visual Studio Community which is free and popular). Have a good day!

Well yes, I see JavaFX is useless af haha, yet I need to use it in the university... We're forced to use Java and JavaFX and it's kind of ew for me... And I'm not even interested in Windows... Not at all, the teachers be like: You have to give us a native Windows image, we don't use Linux here... Oof.

abhinayagarwal commented 3 years ago

Hi @dpkg-i-foo-deb ,

I already tried the samples, same error on Windows.

Can you link to the sample you ran on Windows? I just tried running javafx:jlink on HelloFX from "Commandline -> Modular -> Maven" and it seems to run fine for me.

dpkg-i-foo-deb commented 3 years ago

Curious, I tried the Commandline sample and jlink works... I have also tried running mvn clean javafx:jlink in my project directory and it works as expected... I have no problem in using the terminal to build my project, but it may be useful to know why doesn't it work in Eclipse...

abhinayagarwal commented 3 years ago

Can you list the steps you use to run in Eclipse?

dpkg-i-foo-deb commented 3 years ago

Well, I simply go to run configurations, I add a new maven build and I add clean javafx:jlink and then I have infinite exceptions. It is curious because I can do that on the terminal and no problem.

abhinayagarwal commented 3 years ago

It could be because of various reasons. Unless, there is a way for us to reproduce this, its hard to tell what's going wrong.

As this issue is not directly related to a bug in the plugin, I am closing this. We can re-open this as a bug in maven plugin <-> Eclipse integration once we have a reproducible sample.