opencv-java / getting-started

Getting started with OpenCV and JavaFX
105 stars 176 forks source link

Location is not set #14

Open AhmedAGH opened 5 years ago

AhmedAGH commented 5 years ago

Hi, I have used netbeans instead of eclipse for the project, but I have followed everything mentioned in the tutorial. Yet I get a "Location is not set" error, and here is a printscreen of what I am seeing exactly. Can I know why is the error being caused since I do not really get it and how can it be fixed. Error Edited: I have created another package for the utils.Utils but I assume that has nothing to do with it.

luigidr commented 5 years ago

Hi @AhmedAGH,

that error is typically related to a wrong path declared for the FXMLLoader:

FXMLLoader loader = new FXMLLoader(getClass().getResource("FXHelloCV.fxml"));

Is the FXHelloCV.fxml file still in the same package of FXHelloCV.java? Does it have the same name? Otherwise, you need to change the previous line to match your project...

rafutek commented 5 years ago

Hello, I have the same issue, I moved le .fxml file into the same package but still say "Location is not set".

This is my project architecture: image

I also cloned the project, but Eclipse doesn't find the packages and want me to create a project...

Edit: I resolved it thanks to that post. I put application.css and FXHelloCV.fxml into src/main/resources/, so these files/resources are copied in target/classes/ during compilation. Then in the code you have to add "/" to the file path: FXMLLoader loader = new FXMLLoader(getClass().getResource("/FXHelloCV.fxml"));.