We had lots of trouble with JavaFX in 1226 this past term. It wasn't the lab computers that were the problem (mostly -- we did have some issues on lab computers). The problems were with people who had Java 13 installed on their computers. This page explains how to install and use JavaFX with NetBeans 11.2.
The instructions on this page are based on the following two videos by Dr. John Baugh:
These videos show the Windows version. The Mac versions are probably a bit different -- but maybe the videos will help you to figure it out.
Note that the videos assume that you haven't already installed Apache NetBeans yet. If you've already installed it, you should be able to just do the JavaFX bits. I've separated them out, below.
Most of what's below only needs to be done once. The steps for creating and running a JavaFX Application will need to be done for each JavaFX project you create.
This step is for people who'd like to use OpenJDK instead of Oracle's JDK. If you've already downloaded JDK-13 from Oracle, you can skip this step.
Download OpenJDK 13 from https://jdk.java.net/13/. There are versions for Linux, MacOS, and Windows there.
In these instructions, as in the video, I'm going to assume that the version you get is 13.0.1 for Windows. Of course, if you get a later version (or a Macintosh version), the file names are going to be slightly different.
Save the file in your JavaStuff folder. The name of the file should be something like openjdk-13.0.1_windows-x64_bin.zip.
Extract its contents into the same folder. (Right-click on the file and select the Extract All... command.) That should create a folder called openjdk-13.0.1_windows-x64_bin.
Open that folder, Cut the folder jdk-13.0.1, and then paste it into the JavaStuff folder.
You can now delete the openjdk-13.0.1_windows-x64_bin.zip file and the openjdk-13.0.1_windows-x64_bin folder.
Launch the installer, and it'll take you thru the process of installing NetBeans. Click Next a couple of times, and it'll bring you to a place where you can choose the JDK you want it to use.
Just continue to click thru. When you're done clicking it'll install -- and that may take a while, depending on your computer.
At this point you should be able to create Java console applications (like most of our code is going to be). You should test that by making one and running it.
The first time you try to create a project, NetBeans will need to download some more code. It'll say it's downloading JavaFX, and it really is -- but it's not a version of JavaFX we're going to be able to use.
Important! Make sure you get the same major version of JavaFX as you did of OpenJDK. That'd be version 13 if everything above went as expected.Click the Download button on the JavaFX Windows SDK line.DO NOT get version 11 or version 14! They won't work with OpenJDK 13.
Save the file in your JavaStuff folder. The name of the file should be something like openjfx-13.0.1_windows-x64_bin-sdk.zip.
Extract its contents into the same folder. (Right-click on the file and select the Extract All... command.) That should create a folder called openjfx-13.0.1_windows-x64_bin-sdk.
Open that folder, Cut the folder jdkfx-sdk-13.0.1, and then paste it into the JavaStuff folder.
You can now delete the openjfx-13.0.1_windows-x64_bin-sdk.zip file and the openjfx-13.0.1_windows-x64_bin-sdk folder.
Now click the Add JAR/Folder... button (top button on the right-hand side). Navigate to your JavaStuff folder, open the javafx-sdk-13.0.1 folder, and then the lib folder inside of that.
Select all the jar files in the folder (click the top one, then shift-click on the bottom one). (Do not select src.zip file.) Click the Add JAR/Folder button, then the OK button.
You'll only need to do this the one time -- at least until you upgrade to a later version of OpenJDK/OpenJavaFX.
Now we need to do something a bit weird. Create a new project -- choose Java with Ant > JavaFX in the left-hand panel, then JavaFX FXML Application in the right-hand panels,
NOT JavaFX Applicationand click Next.
NetBeans will say that it's activating JavaFX 2, then bring up a project creation window with a big, red, error message at the bottom. That's fine. Click Cancel and forget about it.
But do have NetBeans create the file, because it'll create a package, too, and OpenJavaFX apparently needs its files to be in a package.
Delete the Java file that NetBeans created for you.
You will then need to add the JavaFX 13 library to the project. Right-click the Libraries folder in your project, select the Add Library... command, then choose JavaFX 13 from the list of global libraries.
If you don't have that library, then you need to go back to the previous section.
Finally, add a new JavaFX Main Class... to the project's package. That's your Application program file.
Error: JavaFX runtime components are missing, and are required to run this applicationor this one:
NOTE: the text inside the "quotation marks" should be the path to the lib folder in the JavaStuff/javafx-sdk-13.0.1 folder you created above. Of course it won't be exactly the path I used.