Error executing code in netbeans (JAVAFX)

Asked

Viewed 212 times

-2

The error is as follows (remembering that only happens in javafx, in swing everything works normal):

Exception in Application start method
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:389)
at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:767)
Caused by: java.lang.RuntimeException: Exception in Application start method
at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:917)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$155(LauncherImpl.java:182)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NullPointerException: Location is required.
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3207)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3175)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3148)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3124)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3104)
at javafx.fxml.FXMLLoader.load(FXMLLoader.java:3097)
at teste.Teste.start(Teste.java:22)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$162(LauncherImpl.java:863)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$175(PlatformImpl.java:326)
at com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$174(PlatformImpl.java:294)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$148(WinApplication.java:191)
… 1 more
Exception running application teste.Teste
C:\Users\Evandro Casanova\Documents\NetBeansProjects\teste\nbproject\build-impl.xml:1052:
The following error occurred while executing this line:
C:\Users\Evandro Casanova\Documents\NetBeansProjects\teste\nbproject\build-impl.xml:806:
Java returned: 1
  • Put your code, the error is here: Location is required. at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3207)

  • Put the code of the main class, which contains the main and start method. The problem is in the start method. The FXML file path must not be correct.

1 answer

0

Evandro, from what I could notice the error is when running the system, probably it is not even opening.
Suggestion:
Check your Start method if your FXML path is correct.
Make sure you are not calling a method on startup.
If you are calling a method on the button, check that in the class where you find the method (Usually the Controller) you have the markup @FXML on top of the method. (Very common mistake forget to put this marking).
If none of this works, see if you can detail the process you did, or the system.

Hug.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.