Hello World with JavaFX 11 (OpenJFX) in Liberica JDK 11

"A revolutionary period starting with everyone's Java OpenJDK! I somehow tried Getting Started with JavaFX with JavaFX 11 of Liberica JDK 11 so I'll take a note.

Most OpenJDK distributions do not include JavaFX (OpenJFX). So, if you follow the procedure of Getting Started with JavaFX obediently, it will take some time. However, if you install Liberica JDK 11 with SDKMAN !, you can easily play with JavaFX 11.

Install Liberica JDK 11 with SDKMAN!

Install Liberica JDK 11 with SDKMAN!. Note that some versions do not include JavaFX. You can check the list of Java versions that can be installed with the sdk list java command.

$ sdk install java 11.0.6.fx-librca

Hello World with Getting Started with JavaFX code

Save the following code with the file name HelloFX.java. It seems that I get the Java and JavaFX versions, generate a Label control with the string including it, and place it in the StackPane layout for display.

HelloFX.java


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();
    }

}

Now let's compile and run it. Be sure to make sure that Liberica JDK 11 is set in SDKMAN !. If it is not set, execute the sdk use java 11.0.6.fx-librca command, and then execute the following command.

$ sdk current java
Using java version 11.0.6.fx-librca
$ javac HelloFX.java
$ java HelloFX

Success if such a screen is displayed.

Hello, JavaFX 11.0.6, running on Java 11.0.6.

I often think that it will be distributed as an application, but if you want a simple GUI with in-house tools, JavaFX using Liberica JDK 11 seems to be useful.


This time, I tried Hello World with JavaFX 11 (OpenJFX) of Liberica JDK 11. When it comes to building a proper development environment, IntelliJ IDEA and Scene Builder should be used. I just took a look, but "The Definitive Guide to Modern Java Clients with JavaFX" described the procedure for building such a development environment.

References

A revolutionary period starting with everyone's Java OpenJDK! The Definitive Guide to Modern Java Clients with JavaFX

Recommended Posts

Hello World with JavaFX 11 (OpenJFX) in Liberica JDK 11
Hello world with Kotlin and JavaFX
"Hello, World!" With Kotlin + CLI in 5 minutes
"Hello World" in Java
Hello world in node.js
Hello World in Java
Hello World with Micronaut
Hello World with Spring Boot!
Hello World with VS Code!
Hello World with Spring Boot
Hello World with SpringBoot / Gradle
Hello, World! With Asakusa Framework!
Spring Boot Hello World in Eclipse
Until "Hello World" with Spring Boot
Hello World with Docker and C
Hello World in java in eclipse now
(Intellij) Hello World with Spring Boot
Hello World with GlassFish 5.1 + Servlet + JSP
Create PDF with itext7 ~ Hello World ~
hello, world in Vanilla Java-EHW2018 "MVP"
"Hello world" for ImageJ with Eclipse
Hello World with GWT 2.8.2 and Maven
Hello world in Java and Gradle
Until you run Hello World of JavaFX with VS Code + Gradle
Compare Hello, world! In Spring Boot with Java, Kotlin and Groovy
Hello World with Eclipse + Spring Boot + Maven
Hello, World! In the bootstrap loader area
Hello world with Java template engine Thymeleaf
[Practice! ] Display Hello World in Spring Boot
Java development with Codenvy: Hello World! Run
Hello world with Kotlin and Tornado FX
How Spring Security works with Hello World
(IntelliJ + gradle) Hello World with Spring Boot
Output Hello World in kotlin's simple main function
Refactored GUI tools made with Java8 + JavaFX in 2016
Hello world! With Spring Boot (Marven + text editor)
Hello World at explosive speed with Spring Initializr! !! !!
Run JSP Hello World with Tomcat on Docker
[Java] Hello World with Java 14 x Spring Boot 2.3 x JUnit 5 ~
Display "Hello World" in the browser using Java
Display "Hello World" in the browser using Java
Show a simple Hello World with SpringBoot + IntelliJ
Try to display hello world with spring + gradle
First JavaFX ~ Easy introduction Hello world GUI creation ~
Easy to display hello world with Rails + Docker
HelloFX with JavaFX
Read "Hello world"
Java, Hello, world!
Java Hello World
Hello World (REST API) with Apache Camel + Spring Boot 2
Organized how to interact with the JDK in stages
Hello World (console app) with Apache Camel + Spring Boot 2