src/main/resources
is the correct location for placing resources in a default SBT configuration.
However, one has to be aware of the difference between getClass.getResource
and ClassLoader.getResource
. Using getClass.getResource("AdoptionForm.fxml")
requires the file to be located in a path which corresponds to the package of the class.
For instance: If the class is located in com.domain.utils
then the resource must be located at src/main/resources/com/domain/utils/AdoptionForm.fxml
.
In order to switch from package-relative locations to absolute locations one can either use ClassLoader.getResource
or just prepend the resource string with a /
.
Example: getClass.getResource("/AdoptionForm.fxml")
loads the resource from src/main/resources/AdoptionForm.fxml