1 overview

I’ve been working on JFX. I’ve written it but I can’t pack it. It’s… Awkward… Java8 is only supported as a JAR package:

Error.... fx:deploy is not availablein this JDK
Copy the code

Fortunately, some third-party tools are mentioned at the end of the document:

2 the environment

  • The IDEA of 2020.1
  • OpenJDK 11
  • OpenJFX 11

Just install IDEA and JDK, and JFX can be introduced in POM.xml.

3 Creating a Project

Select Maven, select Create from Archetype, Add archetype and fill in GroupId:

org.openjfx
Copy the code

And the ArtifactId:

javafx-maven-archetypes
Copy the code

There are the version:

0.0.1
Copy the code

javafx-archetype-fxml
Copy the code

4 Checking Files

After Maven is synchronized, check the project directory for module-info.java and pom.xml. Pom.xml should not look like the following:

5 Modify plug-in dependencies

The default javafX-Maven-plugin version should be 0.0.1:

<plugin>
    <groupId>org.openjfx</groupId>
    <artifactId>javafx-maven-plugin</artifactId>
    <version>0.0.4</version>
    <configuration>
        <stripDebug>true</stripDebug>
        <compress>2</compress>
        <noHeaderFiles>true</noHeaderFiles>
        <noManPages>true</noManPages>
        <launcher>launcher</launcher>
        <jlinkImageName>output</jlinkImageName>
        <jlinkZipName>outputzip</jlinkZipName>
        <mainClass>org.openjfx.App</mainClass>
    </configuration>
</plugin>
Copy the code

Launcher is the executable file name, jlinkImageName is the Image output directory name, jlinkZipName is the zip file name, and mainClass is the mainClass.

6 Run and pack

Maven is run and packaged from the JavafX plug-in in the right column:

7 test

According to the directory of the plug-in, go to the subdirectory under the corresponding target and run it directly:

Project directory/target/output/bin/the launcherCopy the code

Note that this is cross-platform, only need to have the JDK11 environment, just need to publish the ZIP file.

8 demo

  • github
  • Yards cloud

9 Extended Reading

This article is an OpenJFX document that covers:

  • Run Hello World in three ways (JFX+Maven+Gradle)
  • Build run image (CLI+Maven+Gradle+ custom image)
  • IntelliJ NetBeans/Eclipse through three ways (IDE itself + + Gradle Maven) operation and packaged JFX

The link is here.