Reputation: 11
So I've been following the getting started with javaFX tutorial to try and set up a modular FX project on apache netbeans, but I can't seem to figure out how to add the FXML files and CSS files. I managed to create a separate javaFX project that is non-modular with FXML and CSS files: non-modular ver
I did this by right clicking the project and creating a 'new empty FXML' file. However, I don't see this same prompt when clicking on my modular project. basically for my modular project what I did was right click org.openjfx(the name of the package the tutorial made me make)-->new-->other, from here I tried to look for a JavaFX category (followed this youtube tutorial) but couldn't find it.
Would be really grateful for anybody who knows how to add FXML and CSS files to a modular project in netbeans! Thankyou
also here is the error code I receive when running the main class without configuring FXML or CSS files
Error occurred during initialization of boot layer
java.lang.module.FindException: Module format not recognized: C:\java projects\javafx-sdk-16\lib\src.zip
C:\Users\themo\AppData\Local\NetBeans\Cache\12.3\executor-snippets\run.xml:111: The following error occurred while executing this line:
C:\Users\themo\AppData\Local\NetBeans\Cache\12.3\executor-snippets\run.xml:40: Java returned: 1
BUILD FAILED (total time: 0 seconds)
EDIT: There was a really helpful answer on how to build a modular project using Maven but I'm still open to anyone who has a response about building it directly from the IDE.
Upvotes: 0
Views: 877
Reputation: 13859
You are correct to follow the tutorial from getting started with JavaFX tutorial. I would suggest using JavaFX and Netbeans: Modular with Maven
. Once you have created a project, right-click on the package you want to put the Controller
into. Select New
-> Other
-> JavaFX
-> Empty FXML
. Name the FXML
file. Hit Next
. Select Use Java Controller
. Hit Next
. Select Use Cascading Style Sheets
. That should do it.
Upvotes: 2
Reputation: 11
Right click on your project,click Properties Then run and add this to VM option :
--module-path "C:\path to java fx sdk\lib" --add-modules=javafx.controls,javafx.fxml
Upvotes: 1