1、添加JavaFX 11依赖项
1)Maven的Pom.xml配置
<dependencies>
<dependency>
<groupId>javafx</groupId>
<artifactId>javafx.controls</artifactId>
<version>11.0.0</version>
</dependency>
</dependencies>
2)Gradle配置
dependencies {
compile 'javafx:javafx.controls:11.0.0'
}
2、JavaFX Application类
public class JavaFX11 extends Application {
@Override
public void start(Stage stage) throws Exception {
Scene scene = new Scene(new StackPane(new Label("JavaFX 11")), 300, 200);
stage.setScene(scene);
stage.show();
}
}
3、编译代码
<path.to>/jdk-11.jdk/Contents/Home/bin/javac --module-path <path.to>/javafx-sdk-11/lib/ --add-modules=javafx.controls -d class/ src/<package.name>/JavaFX11.java
4、运行上面的JavaFX示例程序
cd class
<path.to>/jdk-11.jdk/Contents/Home/bin/java --module-path <path.to>/javafx-sdk-11/lib/ --add-modules=javafx.controls <package.name>.JavaFX11