0

I am creating a JavaFX Application but the problem is I am getting an InvocationTargetException every time i run the file. I checked this question on StackOverflow and the chained question, but the solution provided there didn't work for me.

The main code is visible in the screen shot shared below. As you can see my ServerFrame.fxml file resides in the same package where my main class ServerFrame.java resides.

my ServerProject.fxml

Community
  • 1
  • 1
Adil
  • 817
  • 1
  • 8
  • 27
  • The root cause shows "Location is required", this may help you : http://stackoverflow.com/questions/20507591/javafx-location-is-required-even-though-it-is-in-the-same-package – Arnaud Jan 04 '16 at 15:06
  • Looks like the path to your fxml is not correct, hence the `NPE`. – hotzst Jan 04 '16 at 15:06
  • @Berger I tried that solution too, but still no luck. – Adil Jan 04 '16 at 15:08
  • @hotzst can you please specify what i should do?? – Adil Jan 04 '16 at 15:08
  • The error message means the `FXMLLoader` cannot find the FXML file. The path looks correct in your source directory, so the most likely explanation is that the FXML file is not getting deployed. Maybe see the discussion in the comments under my answer to [this question](http://stackoverflow.com/questions/34572699/invocativetargetexception-while-trying-to-find-css-file/34572726#34572726) – James_D Jan 04 '16 at 15:27
  • @James_D When I Created a new Swing Application project and moved these files in that project then it worked....However, This isn't working in JavaFx Application Project.Please help . – Adil Jan 04 '16 at 15:37
  • As I said, it hasn't deployed your FXML file. I don't use NetBeans so I don't know the details of how that is configured, but just check the output folder (where the class files are generated) and I think you will see the FXML file is not there. You just need to find the setting to make sure your FXML files are deployed along with the class files. – James_D Jan 04 '16 at 15:39
  • I have noticed some weirdness with NetBeans running locally. Try right clicking the project and selecting "Clean and Build" then try running again. – purring pigeon Jan 04 '16 at 15:51
  • Yup, I figured that out :) – Adil Jan 04 '16 at 16:17

0 Answers0