title: Cannot run JavaFX application from terminal
body: <p>When I try to run a JavaFx application from the terminal, it fails to run showing <code>Error: Could not find or load main class com.test.javafx.HelloWorld</code></p>
  
  <p>Here is my code:</p>
  
  <pre><code>package com.test.javafx;
  
  import javafx.application.Application;
  import javafx.event.ActionEvent;
  import javafx.event.EventHandler;
  import javafx.scene.Scene;
  import javafx.scene.control.Button;
  import javafx.scene.layout.StackPane;
  import javafx.stage.Stage;
  
  public class HelloWorld extends Application {
  
      @Override
      public void start(Stage primaryStage) {
          Button btn = new Button();
          btn.setText("Say 'Hello World'");
          btn.setOnAction(new EventHandler&lt;ActionEvent&gt;() {
  
              @Override
              public void handle(ActionEvent event) {
                  System.out.println("Hello World!");
              }
          });
  
          StackPane root = new StackPane();
          root.getChildren().add(btn);
  
   Scene scene = new Scene(root, 300, 250);
  
          primaryStage.setTitle("Hello World!");
          primaryStage.setScene(scene);
          primaryStage.show();
      }
   public static void main(String[] args) {
          launch(args);
      }
  }
  </code></pre>
  
  <p>Compilation does not show any error and is successful. But trying to run the application results in <code>Error: Could not find or load main class com.test.javafx.HelloWorld</code>. However when I run a simple application, it runs without any errors.</p>
  
  <p>Here is the javap output:</p>
  
  <pre><code>Compiled from "HelloWorld.java"
  public class com.test.javafx.HelloWorld extends javafx.application.Application {
    public com.test.javafx.HelloWorld();
    public void start(javafx.stage.Stage);
    public static void main(java.lang.String[]);
  }
  </code></pre>
  
  <p>I have also tried the following:</p>
  
  <pre><code>java -cp /home/itachi/mycategories/installs/devel/java/jdk/jdk1.8.0_101/jre/lib/ext/jfxrt.jar;." com.test.javafx.HelloWorld
  </code></pre>
  
  <p>but that doesn't work as well.</p>