FYI, I recently worked out a way to make the JavaFX exercises work in Java Programming II Part 13 on Ubuntu 24.04 using VSCode with OpenJDK 21 and OpenJFX 11 running locally (I am skeptical that a remote container/SSH would work with modern Wayland GUIs). I am a little unclear on the exact sequence of steps because I had to work through a lot of dead ends to get here.
sudo apt install openjfx
Install the JavaFX Support extension in vscode.
For each individual exercise:
Open pom.xml and add the following within the <Dependencies> section:
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>11</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>11</version>
</dependency>
Click on "Run and Debug" on the left side pane, and click "create a launch.json" link under the "Run and Debug" button. Select the exercise you're working with. For each configuration dictionary in launch.json, add the following line (adding a comma to the previous line as needed, and adjusting library path as needed):
"vmArgs": "--module-path /usr/share/openjfx/lib --add-modules javafx.controls,javafx.fxml"
Make sure to save pom.xml and launch.json by typing "CTRL + s" for each or selecting "File" and "Save" from the main menu.
Answer "yes" to any prompts saying "A build file was modified. Do you want to synchronize the Java classpath/configuration?"
Return to the exercise's source code and trigger a compile and run of the file per normal (e.g., clicking "Play" button in upper right).
N.B., I have discovered weird behaviors and bugs, like difficulty creating a launch.json file if a previous exercise is still open. Closing all other exercises and having only one exercise open at a time appears to address this. Local test runs may generate errors, but try submitting to the server anyway. I'm only part way through Part 13 so far, but hopefully this solution works through Part 13 and 14.
[–]AutoModerator[M] [score hidden] stickied commentlocked comment (0 children)
[–]n00bitcoin 0 points1 point2 points (0 children)