JavaFX 20 Install

What's Ahead?

This page contains will take you through the process of installing Java 20 with an integrated javaFX SDK. Doing so eliminates a snarl of classpath headaches and allows you to simply use javac and java for building and running JavaFX programs.

Step 1: Install SDKMAN!

Go to this site and do the install. This piece of software makes managing your installed JDKs simple. It will create a .sdkman directory in your home directory. If you install several SDKs, this program makes it easy to choose another SDK as a default or to change to it temporarily.

Step 2: Get the right SDK.

Now do this in a command (cmd/powershell/terminal) window. You will see all of the SDKs available to install. The unix> you see is just a generic system prompt.

unix> sdk list java
================================================================================
Available Java Versions for macOS ARM 64bit
================================================================================
 Vendor        | Use | Version      | Dist    | Status     | Identifier
--------------------------------------------------------------------------------
 Corretto      |     | 20.0.2       | amzn    |            | 20.0.2-amzn 
               |     | 20.0.1       | amzn    |            | 20.0.1-amzn
               |     | 17.0.8       | amzn    |            | 17.0.8-amzn
               |     | 17.0.7       | amzn    |            | 17.0.7-amzn  
               |     | 11.0.20      | amzn    |            | 11.0.20-amzn
               |     | 11.0.19      | amzn    |            | 11.0.19-amzn
               |     | 8.0.382      | amzn    |            | 8.0.382-amzn
               |     | 8.0.372      | amzn    |            | 8.0.372-amzn
 Gluon         |     | 22.1.0.1.r17 | gln     |            | 22.1.0.1.r17-gln
               |     | 22.1.0.1.r11 | gln     |            | 22.1.0.1.r11-gln
 GraalVM CE    |     | 20.0.2       | graalce |            | 20.0.2-graalce
               |     | 20.0.1       | graalce |            | 20.0.1-graalce
               |     | 17.0.8       | graalce |            | 17.0.8-graalce
               |     | 17.0.7       | graalce |            | 17.0.7-graalce
 GraalVM Oracle|     | 20.0.2       | graal   |            | 20.0.2-graal
               |     | 20.0.1       | graal   |            | 20.0.1-graal
               |     | 17.0.8       | graal   |            | 17.0.8-graal
               |     | 17.0.7       | graal   |            | 17.0.7-graal
 Java.net      |     | 22.ea.13     | open    |            | 22.ea.13-open
               |     | 22.ea.12     | open    |            | 22.ea.12-open
               |     | 22.ea.11     | open    |            | 22.ea.11-open 
               |     | 22.ea.10     | open    |            | 22.ea.10-open
               |     | 22.ea.9      | open    |            | 22.ea.9-open  
               |     | 22.ea.8      | open    |            | 22.ea.8-open
               |     | 22.ea.7      | open    |            | 22.ea.7-open  
               |     | 22.ea.6      | open    |            | 22.ea.6-open
               |     | 22.ea.5      | open    |            | 22.ea.5-open  
               |     | 22.ea.4      | open    |            | 22.ea.4-open
               |     | 22.ea.3      | open    |            | 22.ea.3-open   
               |     | 21.ea.35     | open    |            | 21.ea.35-open
               |     | 21.ea.34     | open    |            | 21.ea.34-open  
               |     | 21.ea.33     | open    |            | 21.ea.33-open
               |     | 21.ea.32     | open    |            | 21.ea.32-open  
               |     | 21.ea.31     | open    |            | 21.ea.31-open
               |     | 21.ea.30     | open    |            | 21.ea.30-open  
               |     | 21.ea.29     | open    |            | 21.ea.29-open      
               |     | 21.ea.28     | open    |            | 21.ea.28-open
               |     | 20.0.2       | open    | installed  | 20.0.2-open
 JetBrains     |     | 17.0.8       | jbr     |            | 17.0.8-jbr
               |     | 17.0.7       | jbr     |            | 17.0.7-jbr
               |     | 11.0.14.1    | jbr     |            | 11.0.14.1-jbr
                Liberica      |     | 20.0.2.fx    | librca  |            | 20.0.2.fx-librca
               |     | 20.0.2       | librca  |            | 20.0.2-librca
               |     | 20.0.1.fx    | librca  |            | 20.0.1.fx-librca
               |     | 20.0.1       | librca  |            | 20.0.1-librca
               |     | 17.0.8.fx    | librca  |            | 17.0.8.fx-librca
               |     | 17.0.8.1.fx  | librca  |            | 17.0.8.1.fx-librca
               |     | 17.0.8.1     | librca  |            | 17.0.8.1-librca
               |     | 17.0.8       | librca  |            | 17.0.8-librca
               |     | 17.0.7.fx    | librca  |            | 17.0.7.fx-librca
               |     | 17.0.7       | librca  |            | 17.0.7-librca
               |     | 17.0.1.fx    | librca  | local only | 17.0.1.fx-librca
               |     | 11.0.20.fx   | librca  |            | 11.0.20.fx-librca
               |     | 11.0.20.1.fx | librca  |            | 11.0.20.1.fx-librca
               |     | 11.0.20.1    | librca  |            | 11.0.20.1-librca
               |     | 11.0.20      | librca  |            | 11.0.20-librca
               |     | 11.0.19.fx   | librca  |            | 11.0.19.fx-librca
               |     | 11.0.19      | librca  |            | 11.0.19-librca
               |     | 8.0.382.fx   | librca  |            | 8.0.382.fx-librca
               |     | 8.0.382      | librca  |            | 8.0.382-librca
               |     | 8.0.372.fx   | librca  |            | 8.0.372.fx-librca
               |     | 8.0.372      | librca  |            | 8.0.372-librca
 Liberica NIK  |     | 23.r20       | nik     |            | 23.r20-nik
               |     | 23.r17       | nik     |            | 23.r17-nik
               |     | 23.0.1.r20   | nik     |            | 23.0.1.r20-nik
               |     | 23.0.1.r17   | nik     |            | 23.0.1.r17-nik
               |     | 22.3.3.r17   | nik     |            | 22.3.3.r17-nik
               |     | 22.3.3.r11   | nik     |            | 22.3.3.r11-nik
               |     | 22.3.2.r17   | nik     |            | 22.3.2.r17-nik
               |     | 22.3.2.r11   | nik     |            | 22.3.2.r11-nik
 Microsoft     |     | 17.0.8.1     | ms      |            | 17.0.8.1-ms
               |     | 17.0.8       | ms      |            | 17.0.8-ms
               |     | 17.0.7       | ms      |            | 17.0.7-ms
               |     | 11.0.20.1    | ms      |            | 11.0.20.1-ms
               |     | 11.0.20      | ms      |            | 11.0.20-ms
               |     | 11.0.19      | ms      |            | 11.0.19-ms
 Oracle        |     | 20.0.2       | oracle  |            | 20.0.2-oracle
               |     | 20.0.1       | oracle  |            | 20.0.1-oracle
               |     | 17.0.8       | oracle  |            | 17.0.8-oracle
               |     | 17.0.7       | oracle  |            | 17.0.7-oracle
 SapMachine    |     | 20.0.2       | sapmchn |            | 20.0.2-sapmchn
               |     | 20.0.1       | sapmchn |            | 20.0.1-sapmchn
               |     | 17.0.8       | sapmchn |            | 17.0.8-sapmchn
               |     | 17.0.7       | sapmchn |            | 17.0.7-sapmchn
               |     | 11.0.20      | sapmchn |            | 11.0.20-sapmchn
               |     | 11.0.19      | sapmchn |            | 11.0.19-sapmchn
 Temurin       |     | 20.0.2       | tem     |            | 20.0.2-tem
               |     | 20.0.1       | tem     |            | 20.0.1-tem
               |     | 17.0.8       | tem     |            | 17.0.8-tem
               |     | 17.0.8.1     | tem     |            | 17.0.8.1-tem
               |     | 17.0.7       | tem     |            | 17.0.7-tem
               |     | 11.0.20      | tem     |            | 11.0.20-tem
               |     | 11.0.20.1    | tem     |            | 11.0.20.1-tem
               |     | 11.0.19      | tem     |            | 11.0.19-tem
 Tencent       |     | 17.0.8       | kona    |            | 17.0.8-kona
               |     | 17.0.7       | kona    |            | 17.0.7-kona
               |     | 11.0.20      | kona    |            | 11.0.20-kona
               |     | 11.0.19      | kona    |            | 11.0.19-kona
               |     | 8.0.382      | kona    |            | 8.0.382-kona
               |     | 8.0.372      | kona    |            | 8.0.372-kona
 Zulu          |     | 20.0.2       | zulu    |            | 20.0.2-zulu
               | >>> | 20.0.2.fx    | zulu    | installed  | 20.0.2.fx-zulu
               |     | 20.0.1       | zulu    |            | 20.0.1-zulu
               |     | 20.0.1.fx    | zulu    |            | 20.0.1.fx-zulu
               |     | 17.0.8       | zulu    |            | 17.0.8-zulu
               |     | 17.0.8.fx    | zulu    |            | 17.0.8.fx-zulu
               |     | 17.0.7       | zulu    |            | 17.0.7-zulu
               |     | 17.0.7.fx    | zulu    |            | 17.0.7.fx-zulu
               |     | 11.0.20      | zulu    |            | 11.0.20-zulu
               |     | 11.0.20.fx   | zulu    |            | 11.0.20.fx-zulu
               |     | 11.0.19      | zulu    |            | 11.0.19-zulu
               |     | 11.0.19.fx   | zulu    |            | 11.0.19.fx-zulu
               |     | 8.0.382      | zulu    |            | 8.0.382-zulu
               |     | 8.0.382.fx   | zulu    |            | 8.0.382.fx-zulu
               |     | 8.0.372      | zulu    |            | 8.0.372-zulu
               |     | 8.0.372.fx   | zulu    |            | 8.0.372.fx-zulu
================================================================================
================================================================================
Omit Identifier to install default version 17.0.8.1-tem:
    $ sdk install java
Use TAB completion to discover available versions
    $ sdk install java [TAB]
Or install a specific version by Identifier:
    $ sdk install java 17.0.8.1-tem
Hit Q to exit this list view
================================================================================


This line shows you what I have installed.

              | >>> | 20.0.2.fx    | zulu    | installed  | 20.0.2.fx-zulu

Now install it with the command

unix> sdk install  20.0.2.fx-zulu

It will ask if you want this as your default; choose it.

Test Your Install

Download or copy this and place it in a file named TestFX.java.

import javafx.application.Application;
import javafx.application.Platform;
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.GridPane;

public class TestFX extends Application
{
    GridPane gp;
    @Override
    public void init()
    {
        gp = new GridPane();
    }
    @Override
    public void start(Stage primary)
    {
        Button goButton = new Button("Go");
        Button quitButton = new Button("Quit");
        gp.add(goButton, 0, 0);
        gp.add(quitButton, 1, 0);
        goButton.setOnAction( e ->
        {
            System.out.println("Going....");
        });
        quitButton.setOnAction( e ->
        {
            Platform.exit();
        });
        primary.setScene(new Scene(gp, 300, 300));
        primary.show();
    }
}

Now compile and run with these two commands.

unix> javac TestFX.java
unix> java TestFX

picture of GUI window

This will pop up on your desktop. You are ready for the ewie gooey chewy world of JavaFX programming!

You will notice that, because your window is a child process of the terminal that spawned it, that the terminal is "busy" and there is no prompt. Click on the quit button in the JavaFX window to quit.