Installing Java and JavaFX

rev. 1 June 2021

Installing the Java JDK

Needed for CSC 4240

Begin your journey here. Go to the adoptium.net and do the following. The site automatically detects your OS and offers the correct version.

  1. Download the Latest LTS release.

  2. Run the installer. Then do this in a command window. If you run linux, use --version to see the version. This works on MacOSX and Windoze. You will see your version of Java print out.

Create this file using your text editor.

public class TestJava
{
    public static void main(String[] args)
    {
        System.out.println("Passed!");
    }
}

Navigate your cmd or terminal to the folder containing this file. Then (the $ below is your system prompt), type

$ javac TestJava.java

to compile and

$ java TestJava
Passed!

to run. You are ready to run and compile Java, and you have all you need for 4240.

Installing the JavaFX JDK

Needed for CSC 4280

  1. Go to The BellSoft Site.
  2. Click on Download Current or LTS Release.
  3. Scroll down the page to find your OS.

    picture of BellSoft Site

  4. Select your chip.
  5. Pull down the menu next to the Package label and select FULL JDK.

Restart your command window session if you have one open.

Testing your JavaFX Install

Make this file in a text editor.


import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;
import javafx.scene.control.Button;

public class HelloFX extends Application {

    @Override
    public void start(Stage stage) {
        String javaVersion = System.getProperty("java.version");
        String javafxVersion = System.getProperty("javafx.version");
        Button b = new Button("Quit");
        Label l = new Label("Hello, JavaFX " + javafxVersion 
            + ", running on Java " + javaVersion + ".");
        BorderPane bp = new BorderPane();
        bp.setCenter(l);
        bp.setTop(b);
        b.setOnAction(e -> System.exit(0));
        Scene scene = new Scene(bp, 640, 480);
        stage.setScene(scene);
        stage.show();
    }

    public static void main(String[] args) {
        launch();
    }
}

Now compile and run using the command line. This window should pop up on your screen.

JavaFX Graphics window

Click on the quit button to dismiss it.