Installing the JavaFX JDK on a Mac
Needed for CSC 4280
Install SDKMAN Go to the
Install SDKMAN Site
and do the install. If you have trouble executing a command because
of permissions, use sudo
before the command to execute it
as an administrator.
Next click on the JDK tab. Open another tab and
go here to get the current
version of the Liberica SDK. Then, in your terminal, do
this. Use the version number you learned instead of
.x.y.z-librca
.
$ sdk install java x.y.z-librca
Now close your terminal window and start up a new one. Create the file shown below, compile, and run. If you are successful, you can see a window pop up on your screen. Click on the quit button to dismiss the window.
Installing on Windoze
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();
}
}
Windoze
Here is how to compile the program TextFX.java
in a cmd
or PowerShell window (note no .java extension needed) .
To run and compile, do the following.
unix> javafxc TestFX
To run, do this.
unix> javafx TestFX