title: JavaFX FXML controller ClassNotFoundException
body: <p>I am trying to get a TableView in JavaFX to dynamically display content.</p>
  
  <p>When I run my program I get this error:</p>
  
  <pre><code>java.lang.ClassNotFoundException: UserInterfaceController
  </code></pre>
  
  <p>My controller is named "UserInterfaceController.java", it's under the same package as the FXML file and I have imported the package in the FXML as well. Why can't the controller be found?</p>
  
  <p>FXML file:</p>
  
  <pre><code>&lt;?import javafx.collections.*?&gt; 
  &lt;?import javafx.geometry.Insets?&gt;
  &lt;?import java.lang.*?&gt;
  &lt;?import javafx.scene.*?&gt;
  &lt;?import javafx.scene.control.*?&gt;
  &lt;?import javafx.scene.control.cell.*?&gt;
  &lt;?import javafx.scene.layout.*?&gt;
  &lt;?import d1example2.*?&gt;
  
  &lt;GridPane alignment="center" hgap="10.0" vgap="10.0" fx:controller="UserInterfaceController"
               xmlns:fx="http://javafx.com/fxml"&gt;
       &lt;TableView fx:id="tableView" GridPane.columnIndex="0" GridPane.rowIndex="1"&gt;
            &lt;columns&gt;
            &lt;/columns&gt;    
       &lt;/TableView&gt;
  &lt;/GridPane&gt;
  </code></pre>
  
  <p>Controller:</p>
  
  <pre><code>package d1example2;
  
  import java.net.URL;
  import java.util.ArrayList;
  import java.util.List;
  import java.util.ResourceBundle;
  import javafx.beans.property.SimpleStringProperty;
  import javafx.beans.value.ObservableValue;
  import javafx.collections.FXCollections;
  import javafx.collections.ObservableList;
  import javafx.event.ActionEvent;
  import javafx.fxml.FXML;
  import javafx.fxml.Initializable;
  import javafx.scene.control.Button;
  import javafx.scene.control.Label;
  import javafx.scene.control.TableColumn;
  import javafx.scene.control.TableColumn.CellDataFeatures;
  import javafx.scene.control.TableView;
  import javafx.scene.control.TextField;
  import javafx.scene.control.cell.PropertyValueFactory;
  import javafx.scene.input.MouseEvent;
  import javafx.scene.layout.AnchorPane;
  import javafx.scene.text.Text;
  import javafx.util.Callback;
  
  public class UserInterfaceController implements Initializable {
  
      private Label label;
      @FXML
      private AnchorPane MainPane;
      @FXML
      private TextField FirstField;
      @FXML
      private Text TimesText;
      @FXML
      private Text EqualSign;
      @FXML
      private Text EquationResult;
      @FXML
      private TableColumn&lt;?, ?&gt; HalfColumn;
      @FXML
      private TableColumn&lt;?, ?&gt; DoubleColumn;
      @FXML
      private Button SubmitButton;
  
      @FXML private TableView tableView;
  
      @FXML
      public void initialize(URL url, ResourceBundle rb) {
  
      List&lt;String&gt; columns = new ArrayList&lt;String&gt;();
      columns.add("col1");
      columns.add("col2");
      TableColumn [] tableColumns = new TableColumn[columns.size()];     
      int columnIndex = 0;
      for(int i=0 ; i&lt;columns.size(); i++) {
          final int j = i;
          TableColumn col = new TableColumn(columns.get(i));
          col.setCellValueFactory(new Callback&lt;CellDataFeatures&lt;ObservableList,String&gt;,ObservableValue&lt;String&gt;&gt;(){                   
             public ObservableValue&lt;String&gt; call(CellDataFeatures&lt;ObservableList, String&gt; param) {                                                                                             
                  return new SimpleStringProperty(param.getValue().get(j).toString());                       
              }                   
          });
          tableView.getColumns().addAll(col);
      }       
      ObservableList&lt;String&gt; row = FXCollections.observableArrayList();
      ObservableList&lt;String&gt; row1 = FXCollections.observableArrayList();
      row.addAll("d1");
      row.addAll("d11");
      row1.addAll("d2");
      row1.addAll("d22");
      tableView.getItems().add(row);
      tableView.getItems().add(row1);
      }    
  
      @FXML
      private void handleButtonAction(MouseEvent event) {
  
      }
  
  }
  </code></pre>
  
  <p>Main Class:</p>
  
  <pre><code>package d1example2;
  
  import javafx.application.Application;
  import javafx.fxml.FXMLLoader;
  import javafx.scene.Scene;
  import javafx.scene.layout.Pane;
  import javafx.stage.Stage;
  
  public class D1Example2 extends Application {
  
      @Override
      public void start(Stage primaryStage) throws Exception {
          primaryStage.setTitle("FXML TableView Example");
          Pane myPane = (Pane)FXMLLoader.load(getClass().getResource("UserInterface.fxml"));
          Scene myScene = new Scene(myPane);
          primaryStage.setScene(myScene);
          primaryStage.show();
      }
  
      public static void main(String[] args) {
          launch(args);
      }
  }
  </code></pre>