Guo
Guo

Reputation: 1813

how to config "--enable-preview" when using javafx:jlink in javafx-maven-plugin

I use this plugin in my javafx project: https://github.com/openjfx/javafx-maven-plugin ,

<plugin>
    <groupId>org.openjfx</groupId>
    <artifactId>javafx-maven-plugin</artifactId>
    <version>0.0.4</version>
    <configuration>
        ...
       <launcher>launcher</launcher>
       <mainClass>xxx/com.xxx.Main</mainClass>
    </configuration>
</plugin>

I use java 14 preview features in my code, and use javafx:jlink command to generate Runtime image, but when I run Runtime image, error:
java.lang.UnsupportedClassVersionError: Preview features are not enabled for com/xxx/Main (class file version 58.65535). Try running with '--enable-preview'.

how to config --enable-preview when using javafx:jlink in javafx-maven-plugin

Upvotes: 1

Views: 458

Answers (1)

Patrice GILBERT
Patrice GILBERT

Reputation: 294

Change your javafx-maven-plugin's configuration

<configuration>
        ...
       <launcher>launcher</launcher>
       <mainClass>xxx/com.xxx.Main</mainClass>
       <options>
           <option>--enable-preview</option>
        </options>
</configuration>

Note : Options are also added to jlink image script

Upvotes: 2

Related Questions