javafx-maven-plugin
javafx-maven-plugin copied to clipboard
Different problems on first use of plugin with javafx:compile and javafx:jlink
Hello,
I tried to follow the instructions from the main page in order to compile, run and link a JavaFX project with this Maven plugin.
I started with my own application and ran into problems. So I switched to HelloFX but the problems still remain.
First of all let's talk about my environment
- HW: Mac Book Pro
- OS: OS X El Captian (10.11.6)
- Java: openjdk version "15" 2020-09-15 OpenJDK Runtime Environment AdoptOpenJDK (build 15+36) OpenJDK 64-Bit Server VM AdoptOpenJDK (build 15+36, mixed mode, sharing)
- Maven: Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f) Maven home: /Users/treimers/Programme/apache-maven-3.6.3 Java version: 15, vendor: AdoptOpenJDK, runtime: /Library/Java/JavaVirtualMachines/adoptopenjdk-15.jdk/Contents/Home Default locale: de_DE, platform encoding: UTF-8 OS name: "mac os x", version: "10.11.6", arch: "x86_64", family: "mac"
The documentation states
Create a new Maven project, use an existing one like HelloFX, or use an archetype. The project can be modular or non-modular.
When I try to compile the HelloFX app with
mvn javafx:compile
I am getting an error
[ERROR] Could not find goal 'compile' in plugin org.openjfx:javafx-maven-plugin:0.0.4 among available goals jlink, run -> [Help 1]
So I tried to use
mvn compile
instead. This worked and I could start the app by
mvn javafx:run
But jlink did not work
mvn javafx:jlink
...
[ERROR] Failed to execute goal org.openjfx:javafx-maven-plugin:0.0.4:jlink (default-cli) on project hellofx: Error: jlink requires a module descriptor -> [Help 1]
What might I am doing wrong? Any help appreciated, thanks in advance.
When I try to compile the HelloFX app with
mvn javafx:compile
I am getting an error
[ERROR] Could not find goal 'compile' in plugin org.openjfx:javafx-maven-plugin:0.0.4 among available goals jlink, run -> [Help 1]
Yes, this is a mistake in documentation. The goal javafx:compile
was removed from current version (0.0.4). mvn compile
could be use instead.
So I tried to use
mvn compile
instead. This worked and I could start the app by
mvn javafx:run
In fact, we don't need to run mvn compile
before javafx:run
, but we do when running javafx:jlink
. Next version will fix this (see merged PR #69)
But jlink did not work
mvn javafx:jlink
...
[ERROR] Failed to execute goal org.openjfx:javafx-maven-plugin:0.0.4:jlink (default-cli) on project hellofx: Error: jlink requires a module descriptor -> [Help 1]
What might I am doing wrong?
In order to run a non-modular application you need to create a launcher class which no extend from Application
(more info can be found in the JavaFX official documentation in section Non-modular application).
public class Launcher {
public static void main(String[] args) {
HelloApp.runApp(args);
}
}
public class HelloApp extends Application {
@Override
public void start(Stage stage) {
// here the code
}
public static void runApp(String[] args) {
launch(args);
}
}
Documentation on compile has been fixed with #83