title: LoadException while loading fxml file
body: <p>Hi i am using javaFx and i am new to it.
  i need help in it.
  while running the main application i am getting error of javafx.fxml.LoadException: </p>
  
  <p>Please Help.</p>
  
  <p>Code:
  Main Code</p>
  
  <pre><code>package mainApp;
  
  
  import controller.LoginController;
  import javafx.application.Application;
  import javafx.fxml.FXMLLoader;
  import javafx.stage.Stage;
  import javafx.scene.Scene;
  import javafx.scene.layout.AnchorPane;
  
  public class Main extends Application {
      @Override
      public void start(Stage primaryStage) {
          try {
              //Create a loader for the UI components
              FXMLLoader loader = new FXMLLoader();
                      loader.setLocation(Main.class.getResource("/view/loginFx.fxml"));
              //Inflate the view using the loader
              AnchorPane root = (AnchorPane) loader.load();
              //Set window title
              primaryStage.setTitle("Welcome");
              //Create a scene with the inflated view
              Scene scene = new Scene(root);
              //Set the scene to the stage
              primaryStage.setScene(scene);
              //Get the controller instance from the loader
              LoginController controller = loader.getController();
              //Set the parent stage in the controller
              controller.setDialogStage(primaryStage);
              //Show the view
              primaryStage.show();
          } catch(Exception e) {
              //System.out.println("Error occured while inflating view: " + e);
              e.printStackTrace();
          }
      }
  
  
      public static void main(String[] args) {
          launch(args);
      }
  }
  </code></pre>
  
  <p>fxml file</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  
  &lt;?import java.net.*?&gt;
  &lt;?import javafx.geometry.*?&gt;
  &lt;?import javafx.scene.control.*?&gt;
  &lt;?import javafx.scene.layout.*?&gt;
  &lt;?import javafx.scene.text.*?&gt;
  &lt;?import java.lang.*?&gt;
  &lt;?import javafx.scene.layout.AnchorPane?&gt;
  
  &lt;AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8.0.65" xmlns:fx="http://javafx.com/fxml/1" fx:controller="login.controller.LoginController"&gt;
      &lt;children&gt;
          &lt;Label layoutX="113.0" layoutY="102.0" text="UserName" /&gt;
          &lt;Label layoutX="116.0" layoutY="173.0" text="Password" /&gt;
          &lt;TextField fx:id="UserName" layoutX="200.0" layoutY="98.0" /&gt;
          &lt;Button layoutX="242.0" layoutY="251.0" mnemonicParsing="false" onAction="#loginbutton" text="Login" /&gt;
          &lt;Text fx:id="username" layoutX="200.0" layoutY="400.0" /&gt;
        &lt;PasswordField layoutX="200.0" layoutY="169.0" /&gt;
        &lt;Label layoutX="54.0" layoutY="45.0" prefHeight="17.0" prefWidth="130.0" text="Welcome" /&gt;
     &lt;/children&gt;
  
  &lt;/AnchorPane&gt;
  </code></pre>
  
  <p>Controller file:</p>
  
  <pre><code>package controller;
  
  
  //import javafx.event.ActionEvent;
  import javafx.fxml.FXML;
  import javafx.scene.control.TextField;
  //import javafx.scene.text.Text;
  import javafx.stage.Stage;
  import javafx.stage.WindowEvent;
  
  import model.Login;
  import dao.UserDao;
  
  public class LoginController {
      //This is the parent stage
          private Stage dialogStage;
  
          //This is the Text box element in the view for name of bank
          @FXML
          private TextField username;
          //Method to set the parent stage of the current view
          public void setDialogStage(Stage dialogStage) {
              this.dialogStage = dialogStage;
          }
          public void loginbutton() {
              //Extract the data from the view elements
              String username = this.username.getText();
          //  String address = this.address.getText();
              //Validate the data
              if(username == null || username.trim().equals("")) {
                  return;
              }
  
          Login login = new Login();
          login.setName(username);
          UserDao u = new UserDao();
          u.create(login);
          close();
          }
  
          private void close() {
              dialogStage.fireEvent(new WindowEvent(dialogStage,WindowEvent.WINDOW_CLOSE_REQUEST));
          }
  
      }
  </code></pre>
  
  <p>Please tell me what is the issue 
  i am getting following error:
  javafx.fxml.LoadException: 
  /C:/Users/Neel-Megha/workspace/User/bin/view/loginFx.fxml:11</p>
  
  <pre><code>at javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2601)
  at javafx.fxml.FXMLLoader.access$700(FXMLLoader.java:103)
  at javafx.fxml.FXMLLoader$ValueElement.processAttribute(FXMLLoader.java:922)
  at javafx.fxml.FXMLLoader$InstanceDeclarationElement.processAttribute(FXMLLoader.java:971)
  at javafx.fxml.FXMLLoader$Element.processStartElement(FXMLLoader.java:220)
  at javafx.fxml.FXMLLoader$ValueElement.processStartElement(FXMLLoader.java:744)
  at javafx.fxml.FXMLLoader.processStartElement(FXMLLoader.java:2707)
  at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2527)
  at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2441)
  at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2409)
  at mainApp.Main.start(Main.java:19)
  at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$163(LauncherImpl.java:863)
  at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$176(PlatformImpl.java:326)
  at com.sun.javafx.application.PlatformImpl.lambda$null$174(PlatformImpl.java:295)
  at java.security.AccessController.doPrivileged(Native Method)
  at 
  
  com.sun.javafx.application.PlatformImpl.lambda$runLater$175(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$149(WinApplication.java:191)
      at java.lang.Thread.run(Thread.java:745)
  Caused by: java.lang.ClassNotFoundException: login.controller.LoginController
      at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
      at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
      at javafx.fxml.FXMLLoader$ValueElement.processAttribute(FXMLLoader.java:920)
      ... 17 more
  </code></pre>