Leila
Leila

Reputation: 21

error: java.lang.NoSuchMethodException main([Ljava.lang.String;)

This is my main class for running a simple frame have been created by JavaFX but I got this error

Exception in Application start method Exception in thread "main"
java.lang.NoSuchMethodException: controller.TestFrame.main([Ljava.lang.String;)
    at java.lang.Class.getMethod(Class.java:1786)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:119)
public class TestFrame extends Application {

    @Override
    public void start(Stage primaryStage) throws Exception {

        primaryStage.setTitle("Frame1 Title");
        primaryStage.setScene(
                new Scene(
                        (Parent) FXMLLoader.load(getClass().getResource("/view/Frame1.fxml"))
                        , 400
                        , 500));
        primaryStage.show();

    }

}

Upvotes: 0

Views: 4401

Answers (1)

saeid rastak
saeid rastak

Reputation: 353

If you want run this class directly, you must add this method to your class:

public static void main(String[] args) {
        launch(args);
}

Upvotes: 1

Related Questions