title: javafx fxml program error(no main method)
body: <p>i'm fairly new to javafx and fxml. I'm trying to teach myself! However, when I was creating a program for a simple login GUI I came into an issue when I finally tried to run my program. It told me there was no main method in my class and I'm unsure of how to fix it. Any ideas?</p>
  
  <p>My program creates a login screen and when you enter "test" for the username and password it'll take you to another scene.</p>
  
  <p><strong>Here is my Login.java</strong></p>
  
  <pre><code>package com;
  
      import javafx.application.Application;
      import javafx.fxml.FXMLLoader;
      import javafx.stage.Stage;
      import javafx.scene.Parent;
      import javafx.scene.Scene;
  
      /**
       *
       * @author Tyler
       */
      public class Login extends Application{
  
          @Override
          public void start(Stage stage) throws Exception {
              Parent root = FXMLLoader.load(getClass().getResource("Login.fxml"));
              Scene scene = new Scene(root);
              stage.setScene(scene);
              stage.setTitle("Login");
              stage.show();
          }
  
      }
  </code></pre>
  
  <p><strong>Here is my LoginController.java</strong></p>
  
  <pre><code>package com;
  
  import java.net.URL;
  import java.util.ResourceBundle;
  import javafx.application.Application;
  import javafx.event.ActionEvent;
  import javafx.fxml.FXML;
  import javafx.fxml.FXMLLoader;
  import javafx.fxml.Initializable;
  import javafx.scene.Node;
  import javafx.scene.Parent;
  import javafx.scene.Scene;
  import javafx.scene.control.Label;
  import javafx.scene.control.PasswordField;
  import javafx.scene.control.TextField;
  import javafx.stage.Stage;
  
  /**
   * FXML Controller class
   *
   * @author Tyler
   */
  public class LoginController implements Initializable {
  
      @FXML
      private Label lblMessage; 
      @FXML
      private TextField txtUsername;
      @FXML
      private PasswordField txtPassword;
      @FXML
      private void btnLoginAction(ActionEvent event) throws Exception{
          if(txtUsername.getText().equals("test") &amp;&amp; txtPassword.getText().equals("test")){
              ((Node) (event.getSource())).getScene().getWindow().hide();
              Parent parent = FXMLLoader.load(getClass().getResource("DateSelection.fxml"));
              Stage stage  = new Stage();
              Scene scene = new Scene(parent);
              stage.setScene(scene);
              stage.setTitle("Date Selection");
              stage.show();
          }else{
              lblMessage.setText("Username or Password is invalid!");
          }
      }
      /**
       * Initializes the controller class.
       * @param url
       * @param rb
       */
      @Override
      public void initialize(URL url, ResourceBundle rb) {
          // TODO
      }    
  
  }
  </code></pre>
  
  <p><strong>Here is my Login.fxml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  
  &lt;?import javafx.scene.text.*?&gt;
  &lt;?import java.lang.*?&gt;
  &lt;?import java.util.*?&gt;
  &lt;?import javafx.scene.*?&gt;
  &lt;?import javafx.scene.control.*?&gt;
  &lt;?import javafx.scene.layout.*?&gt;
  
  &lt;AnchorPane id="AnchorPane" fx:id="lblMessage" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.LoginController"&gt;
     &lt;children&gt;
        &lt;PasswordField fx:id="txtPassword" layoutX="200.0" layoutY="200.0" prefHeight="30.0" prefWidth="200.0" promptText="Password" /&gt;
        &lt;TextField fx:id="txtUsername" layoutX="200.0" layoutY="140.0" prefHeight="30.0" prefWidth="200.0" promptText="Username" /&gt;
        &lt;Button fx:id="btnLogin" layoutX="269.0" layoutY="251.0" mnemonicParsing="false" onAction="#btnLoginAction" prefHeight="30.0" text="Login"&gt;
           &lt;font&gt;
              &lt;Font size="14.0" /&gt;
           &lt;/font&gt;&lt;/Button&gt;
        &lt;Label fx:id="lblMessage" layoutX="283.0" layoutY="71.0" text="Label" /&gt;
     &lt;/children&gt;
  &lt;/AnchorPane&gt;
  </code></pre>
  
  <p><strong><code>Here is my DateSelectionController.java</code></strong></p>
  
  <pre><code>package com;
  
  import java.net.URL;
  import java.util.ResourceBundle;
  import javafx.fxml.Initializable;
  
  /**
   * FXML Controller class
   *
   * @author Tyler
   */
  public class DateSelectionController implements Initializable {
  
      /**
       * Initializes the controller class.
       */
      @Override
      public void initialize(URL url, ResourceBundle rb) {
          // TODO
      }    
  
  }
  </code></pre>
  
  <p><strong>Here is my DateSelection.fxml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  
  &lt;?import javafx.scene.text.*?&gt;
  &lt;?import java.lang.*?&gt;
  &lt;?import java.util.*?&gt;
  &lt;?import javafx.scene.*?&gt;
  &lt;?import javafx.scene.control.*?&gt;
  &lt;?import javafx.scene.layout.*?&gt;
  
  
  &lt;AnchorPane id="AnchorPane" prefHeight="400.0" prefWidth="600.0" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/8" fx:controller="com.DateSelectionController"&gt;
     &lt;children&gt;
        &lt;Label layoutX="191.0" layoutY="164.0" text="Welcome"&gt;
           &lt;font&gt;
              &lt;Font name="System Bold" size="50.0" /&gt;
           &lt;/font&gt;
        &lt;/Label&gt;
     &lt;/children&gt;
  &lt;/AnchorPane&gt;
  </code></pre>