Giter Club home page Giter Club logo

maven-jlink-plugin-javafx's Introduction

Using maven-jlink-plugin with JavaFX

This is a playground to use maven-jlink-plugin with JavaFX application.

Create native image

mvn jlink:jlink

Problem

Using v3.1.0 of the plugin, mvn jlink:jlink fails with the following exception:

Error: automatic module cannot be used with jlink: javafx.graphicsEmpty

Plugin logs have the following lines in them:

[INFO] --- maven-jlink-plugin:3.1.0:jlink (default-cli) @ hellofx ---
[INFO]  -> module: javafx.base ( ~/.m2/repository/org/openjfx/javafx-base/13/javafx-base-13-linux.jar )
[INFO]  -> module: javafx.graphicsEmpty ( ~/.m2/repository/org/openjfx/javafx-graphics/13/javafx-graphics-13.jar )
[INFO]  -> module: hellofx ( ~/Documents/git/samples/IDE/IntelliJ/Modular/Maven/hellofx/target/classes )
[INFO]  -> module: javafx.baseEmpty ( ~/.m2/repository/org/openjfx/javafx-base/13/javafx-base-13.jar )
[INFO]  -> module: javafx.controls ( ~/.m2/repository/org/openjfx/javafx-controls/13/javafx-controls-13-linux.jar )
[INFO]  -> module: javafx.graphics ( ~/.m2/repository/org/openjfx/javafx-graphics/13/javafx-graphics-13-linux.jar )
[INFO]  -> module: javafx.fxml ( ~/.m2/repository/org/openjfx/javafx-fxml/13/javafx-fxml-13-linux.jar )
[INFO]  -> module: javafx.fxmlEmpty ( ~/.m2/repository/org/openjfx/javafx-fxml/13/javafx-fxml-13.jar )
[INFO]  -> module: javafx.controlsEmpty ( ~/.m2/repository/org/openjfx/javafx-controls/13/javafx-controls-13.jar )

JavaFX tries to be platform independent by hiding the platform specific jars behind empty dependencies. If we add the following dependency to an application running on Linux:

<dependency>
    <groupId>org.openjfx</groupId>
    <artifactId>javafx-graphics</artifactId>
    <version>13</version>
</dependency>

It will be resolved into javafx-graphics-13.jar and javafx-graphics-13-linux.jar. The former is an empty jar with Automatic-Module-Name set as javafx.graphicsEmpty. More information on this can be found here: http://mail.openjdk.java.net/pipermail/openjfx-dev/2018-August/022313.html

Solution

Most Java(FX) applications with a main class will add a launcher configuration to the plugin. If a launcher is found, maven-jlink-plugin can skip adding the entire module-path to the add-modules list and add only the base module to it. This is how javafx-maven-plugin's jlink goal works.

This approach may have some side-effects and needs to be explored.

maven-jlink-plugin-javafx's People

Contributors

abhinayagarwal avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.