openjfx / javafx-maven-plugin

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

JDK16 - Unrecognized option: --output for javafx:jlink #135

Closed ghost closed 3 years ago

ghost commented 3 years ago

javafx:run executes successfully javafx:jlink results in the following error (targeted to the top level error can provide full, large, error if needed)

The error:

[INFO] --- javafx-maven-plugin:0.0.6:jlink (default-cli) @ LifeSimRPG ---
[INFO] Toolchain in javafx-maven-plugin JDK[C:\Users\diont\.jdks\openjdk-16.0.2]
Unrecognized option: --output
Error: Could not create the Java Virtual Machine.

--output seems to be from the jlinkImageName option I think.

pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>org.dionthorn</groupId>
    <artifactId>LifeSimRPG</artifactId>
    <version>1.0-SNAPSHOT</version>
    <name>LifeSimRPG</name>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <junit.version>5.7.1</junit.version>
        <maven.compiler.source>16</maven.compiler.source>
        <maven.compiler.target>16</maven.compiler.target>
        <java.version>16</java.version>
    </properties>

    <dependencies>
        <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>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.panteleyev</groupId>
                <artifactId>jpackage-maven-plugin</artifactId>
                <version>1.5.1</version>
                <configuration>
                    <name>LifeSimRPG</name>
                    <appVersion>0.0.1</appVersion>
                    <vendor>org.dionthorn</vendor>
                    <destination>Runtime</destination>
                    <module>LifeSimRPG/org.dionthorn.lifesimrpg.App</module>
                    <runtimeImage>target/App</runtimeImage>
                    <type>MSI</type>
                    <winDirChooser>true</winDirChooser>
                    <winShortcut>true</winShortcut>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
                <configuration>
                    <source>16</source>
                    <target>16</target>
                    <verbose>true</verbose>
                    <fork>true</fork>
                    <compilerVersion>16</compilerVersion>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.openjfx</groupId>
                <artifactId>javafx-maven-plugin</artifactId>
                <version>0.0.6</version>
                <executions>
                    <execution>
                        <!-- Default configuration for running with: mvn clean javafx:run -->
                        <id>default-cli</id>
                        <configuration>
                            <noHeaderFiles>true</noHeaderFiles>
                            <stripDebug>true</stripDebug>
                            <noManPages>true</noManPages>
                            <launcher>App</launcher>
                            <mainClass>LifeSimRPG/org.dionthorn.lifesimrpg.App</mainClass>
                            <jlinkImageName>App</jlinkImageName>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-toolchains-plugin</artifactId>
                <version>3.0.0</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>toolchain</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <toolchains>
                        <jdk>
                            <version>16</version>
                        </jdk>
                    </toolchains>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

I feel like I'm missing something obvious but I just can't get it to play nice. The toolchains.xml is new for me so not sure if that is correct setup. Could we maybe get an update on how to get the JLink working minimally with JDK 16 or am I moving too fast >.>?

ghost commented 3 years ago

Here is toolchains.xml it wasn't rendering very well in main post for some reason:

<toolchains xmlns="http://maven.apache.org/TOOLCHAINS/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:schemaLocation="http://maven.apache.org/TOOLCHAINS/1.1.0 http://maven.apache.org/xsd/toolchains-1.1.0.xsd">
    <toolchain>
        <type>jdk</type>
        <provides>
            <version>16</version>
        </provides>
        <configuration>
            <jdkHome>C:\Users\diont\.jdks\openjdk-16.0.2</jdkHome>
        </configuration>
    </toolchain>

</toolchains>
ghost commented 3 years ago

I think I was over complicating it. I made a minimal test case and it seems to work without error.

pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>org.dionthorn</groupId>
    <artifactId>TestMaven</artifactId>
    <version>1.0-SNAPSHOT</version>
    <name>TestMaven</name>

    <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>16</version>
        </dependency>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-fxml</artifactId>
            <version>16</version>
        </dependency>

        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-api</artifactId>
            <version>${junit.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-engine</artifactId>
            <version>${junit.version}</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
                <configuration>
                    <source>16</source>
                    <target>16</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.openjfx</groupId>
                <artifactId>javafx-maven-plugin</artifactId>
                <version>0.0.6</version>
                <executions>
                    <execution>
                        <!-- Default configuration for running with: mvn clean javafx:run -->
                        <id>default-cli</id>
                        <configuration>
                            <mainClass>org.dionthorn.testmaven/org.dionthorn.testmaven.HelloApplication</mainClass>
                            <noHeaderFiles>true</noHeaderFiles>
                            <stripDebug>true</stripDebug>
                            <noManPages>true</noManPages>
                            <launcher>App</launcher>
                            <jlinkImageName>App</jlinkImageName>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.panteleyev</groupId>
                <artifactId>jpackage-maven-plugin</artifactId>
                <version>1.5.1</version>
                <configuration>
                    <name>Test</name>
                    <appVersion>0.0.1</appVersion>
                    <vendor>org.dionthorn</vendor>
                    <destination>Runtime</destination>
                    <module>org.dionthorn.testmaven/org.dionthorn.testmaven.HelloApplication</module>
                    <runtimeImage>target/App</runtimeImage>
                    <type>MSI</type>
                    <winDirChooser>true</winDirChooser>
                    <winShortcut>true</winShortcut>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

module-info.java

module org.dionthorn.testmaven {
    requires javafx.controls;
    requires javafx.fxml;

    opens org.dionthorn.testmaven to javafx.fxml;
    exports org.dionthorn.testmaven;
}

I removed toolchains and other plugins for minimalism. Must have been some configuration error I wasn't catching.

dwhitla commented 3 years ago

No this is actually a bug - your minimal config just avoids it by accident. If you turn up the logging using your first config you will see the plugin is trying to run java instead of jlink - and --output is not an option for the java executable.

SoleRay commented 8 months ago

No this is actually a bug - your minimal config just avoids it by accident. If you turn up the logging using your first config you will see the plugin is trying to run java instead of jlink - and --output is not an option for the java executable.

Thank you very much for your answer,for I just come across the same question.As you said, I use 'java' command but not 'jlink' command for !

the config should be like: `

org.openjfx
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.8</version>
<configuration>
    <mainClass>module-demo/com.demo.MainApplication</mainClass>
    <jlinkExecutable>/xxxx/jdk17/bin/jlink</jlinkExecutable>
</configuration>

`

my previous error config is `

org.openjfx
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.8</version>
<configuration>
    <mainClass>module-demo/com.demo.MainApplication</mainClass>
    <jlinkExecutable>/xxxx/jdk17/bin/java</jlinkExecutable>
</configuration>

`