I have downloaded JavaFX SDK, unpacked it and set a PATH_TO_FX
system variable, following this instructions. I used following code example:
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
public class HelloFX extends Application {
@Override
public void start(Stage stage) {
String javaVersion = System.getProperty("java.version");
String javafxVersion = System.getProperty("javafx.version");
Label l = new Label("Hello, JavaFX " + javafxVersion + ", running on Java " + javaVersion + ".");
Scene scene = new Scene(new StackPane(l), 640, 480);
stage.setScene(scene);
stage.show();
}
public static void main(String[] args) {
launch();
}
}
Tried to compile it with the suggested pattern:
javac --module-path $PATH_TO_FX --add-modules javafx.controls HelloFX.java
But compiler throws an error: module not found: javafx.controls. Windows 10. Java and JavaFX versions is 11.0.1
Again: I DID ADD the line --add-modules javafx.controls
I had to also include the 'lib' directory: --module-path %PATH_TO_FX%;%PATH_TO_FX%\lib
to make it compile.
I'm using gradle
and below build.gralde
works fine for me (org.beryx.jlink
is optional to build standalone distribution).
plugins {
id 'application'
id 'org.openjfx.javafxplugin' version '0.0.5'
id "org.beryx.jlink" version "2.3.0" //optional for jlink
}
repositories {
mavenCentral()
}
javafx {
modules = [ 'javafx.controls' ]
}
mainClassName = 'gui.Main'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With